fix: exclude unshared prereleases from range intersections - #901
Open
ryanchou1994 wants to merge 1 commit into
Open
fix: exclude unshared prereleases from range intersections#901ryanchou1994 wants to merge 1 commit into
ryanchou1994 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
intersects('>1.0.0 <2.0.0', '^2.0.0-0')currently returnstrue, although no version satisfies both ranges with the default prerelease rules. WithincludePrerelease: true,2.0.0-0is a valid intersection and the result should remaintrue.This adds a check after the existing comparator-set intersection succeeds. If both sets do not opt into a common prerelease tuple, their intersection must contain a stable version. Check the least possible stable version against each original set separately, preserving each set's prerelease permissions. This also covers empty gaps between adjacent stable versions and numeric-component rollover.
Related to #345 and its requested
includePrerelease: falsecase. The change is limited toRange.intersects; it does not change version ordering, the existing shared-prerelease path, or address every known intersection defect.Validation:
--jobs=2for its two-CPU allocation.The extra check has a measurable cost: a five-round Linux microbenchmark measured public calls at 1.04–1.38× baseline. The smallest prebuilt-Range case was 9.9→31.1 ms per 100,000 calls (about 0.21 µs extra per call). No cache or tooling changes are included.