Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding prereleases from a constraint doesn't work correctly #4

Closed
apparentlymart opened this issue Jun 30, 2023 · 1 comment · Fixed by #5
Closed

Excluding prereleases from a constraint doesn't work correctly #4

apparentlymart opened this issue Jun 30, 2023 · 1 comment · Fixed by #5

Comments

@apparentlymart
Copy link
Owner

This was originally reported over in hashicorp/terraform#33452 and so there's more context there, but the short version is that given a contradictory (and Ruby-style) constraint like 1.0.0-beta1, != 1.0.0-beta1 the resulting version set operators don't seem to be correct.

I'd expect that constraint to produce something like this...

versions.Intersection(
	versions.Released,
	versions.Only(MustParseVersion(`1.0.0-beta1`)),
	versions.All.Subtract(Only(MustParseVersion(`1.0.0-beta1`))),
),

...but instead it currently produces the following confusing expression:

versions.Union(
    versions.Only(versions.MustParseVersion("1.0.0-beta1")),
    versions.Intersection(
        versions.Released,
        versions.Only(versions.MustParseVersion("1.0.0-beta1")),
        (versions.All).Subtract(versions.Only(versions.MustParseVersion("1.0.0-beta1"))),
    )
)

This produces the wrong behavior because, after some reduction, this is effectively "1.0.0-beta1 OR NOT 1.0.0-beta1", which therefore matches -- any version is either that version or not -- when it should be requiring both and therefore reducing to an empty set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant