Skip to content

Do not compact a dev-free constraint into a bare != that matches dev - #184

Open
dngr2 wants to merge 1 commit into
composer:mainfrom
dngr2:compact-bare-not-equal-dev
Open

Do not compact a dev-free constraint into a bare != that matches dev#184
dngr2 wants to merge 1 commit into
composer:mainfrom
dngr2:compact-bare-not-equal-dev

Conversation

@dngr2

@dngr2 dngr2 commented Aug 18, 2026

Copy link
Copy Markdown

compactConstraint() rewrites < N || > N into != N. Those are not equivalent
once dev versions are involved: a bare != N matches every dev-* version, while
< N || > N matches none. So compacting a numeric-only constraint that covers the
whole line except N (and matches no dev branch) into a bare != silently starts
matching every dev branch.

Skip the swap when it would produce that bare != for a constraint whose branch
set isn't already "all dev". A bounded conjunctive != such as [!= 3 < 5] keeps
a numeric bound and is unaffected.

Added a test that compacts > 1.0.0 != 2.0.0 || < 1.9.0 and checks the result still
excludes dev-foo and stays an exact subset of the original both ways.

The < N || > N to != N swap in compactConstraint changes dev-branch matching:
a bare != N matches every dev-* version, while < N || > N matches none. So
"> 1.0.0 != 2.0.0 || < 1.9.0" (matches no branch) compacted to "!= 2.0.0"
(matches every branch), and Semver::satisfies flipped after compaction. Skip
the swap when it would produce a bare != for a constraint whose branches do not
already include all dev versions; a bounded conjunctive != (e.g. [!= 3 < 5])
still keeps a numeric bound and is unaffected.
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.

1 participant