Skip to content

fix: use OR logic for != wildcard range expansion - #84

Open
deepakganesh78 wants to merge 1 commit into
blang:masterfrom
deepakganesh78:fix/issue80-neq-wildcard-or
Open

fix: use OR logic for != wildcard range expansion#84
deepakganesh78 wants to merge 1 commit into
blang:masterfrom
deepakganesh78:fix/issue80-neq-wildcard-or

Conversation

@deepakganesh78

Copy link
Copy Markdown

Fixes #80

Problem

The != wildcard expansion (e.g. !=1.0.x) was incorrectly joining its two range bounds (<1.0.0 and >=1.1.0) with AND logic within the same comparator group. Since no version can satisfy both <1.0.0 AND >=1.1.0 simultaneously, the resulting range was unsatisfiable — every version failed the check.

Root Cause

In expandWildcardVersion(), the != case appended <flatVersion to newParts and then the incremented >=version was also appended to newParts. Since all entries in a single newParts slice are AND'd together during range evaluation, this produced an impossible constraint.

Fix

Split the != wildcard expansion into separate OR parts. !=1.0.x now correctly expands to <1.0.0 || >=1.1.0, meaning a version matches if it is outside the 1.0.x range.

Reproduction

go r, _ := semver.ParseRange("!=1.0.x") v, _ := semver.Parse("1.1.1") fmt.Println(r(v)) // Before: false, After: true

Validation

  • go test ./... passes (root module + v4)
  • go vet ./... clean
  • gofmt clean
  • Regression tests added for both patch and minor wildcard cases

The != wildcard expansion (e.g. !=1.0.x) was incorrectly joining its
two range bounds (<1.0.0 and >=1.1.0) with AND logic, making the
resulting range unsatisfiable (no version can be both <1.0.0 AND >=1.1.0).

The correct semantics is OR: a version satisfies !=1.0.x if it is
either <1.0.0 OR >=1.1.0 (i.e., outside the 1.0.x range).

This fix splits the != wildcard expansion into separate OR parts
instead of combining them in a single AND group.

Fixes blang#80

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 this pull request may close these issues.

Not equal expression with wildcards !=1.0.x checks failure

1 participant