Skip to content

fix: ignore empty subset branches regardless of order - #919

Open
FanWu-ai wants to merge 1 commit into
npm:mainfrom
FanWu-ai:fix/subset-empty-branch-order-20261010
Open

FanWu-ai wants to merge 1 commit into
npm:mainfrom
FanWu-ai:fix/subset-empty-branch-order-20261010

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 9, 2026

Copy link
Copy Markdown

subset('1.0.0 || >2 <1', '>=1 <2') returns false, while reversing the two branches returns true. The contradictory branch matches no versions and should not change the union.

The sawNonNull flag persists between outer-loop iterations. After a valid subset branch sets it to true, a later empty branch inherits that state and causes the whole check to fail. Initialize the flag separately for each candidate branch.

The regressions cover contradictory bounds, incompatible exact versions, exact versions excluded by bounds, branch permutations, multiple superset alternatives, loose/prerelease options, and a genuinely non-subset branch that must still return false.

This is separate from #854 and #894, which address coverage by a union of superset branches. Their current patches retain the cross-branch flag state; the minimal example here has only one superset branch.

Validation on Linux / Node 24.19.0:

  • Full pristine npm test: 51 test files passing, 100% statement/branch/function/line coverage, ESLint and template checks passing.
  • Full regression run with unchanged source: nine new assertions fail in test/ranges/subset.js; 50 other test files pass.
  • Final npm test: all 51 test files pass, 100% coverage, ESLint and template checks pass.
  • 134,784 additional assertions cover empty-branch invariance and an independent finite exact-version union oracle.
  • git diff --check passes.

The remote CI platform/Node-version matrix has not been run locally. No dependencies, coverage requirements, or tooling are changed.

AI assistance was used to prepare the implementation and regression tests.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 9, 2026 21:38
@FanWu-ai
FanWu-ai requested a review from a team as a code owner October 9, 2026 21:38
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