Repository navigation
Conversation
Reject main-component overflow before mutation and preserve valid prerelease promotion behavior. Cover the public null result, class errors, boundary increments and unchanged failed instances.
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.
What / Why
Main-version increments can exceed the numeric limit enforced by the constructor and return versions that the same package rejects:
semver.valid('1.2.9007199254740992')isnull. Repeated increments of the same instance can then stop advancing because of numeric precision. This affects extreme component values accepted by the parser.Change and scope
Guard main-component increments against
MAX_SAFE_INTEGER, using the constructor's existingTypeErrormessages. The publicinc()wrapper retains its existingnullfailure convention. Check before resetting lower components or clearing prerelease information so a rejected increment leaves the instance unchanged.All seven affected release modes are covered, together with successful increments to the limit, prerelease promotion without a component increment, and resets of large lower components. Numeric prerelease identifier arithmetic is unchanged. That is the separate subject of #916.
The CLI's existing invalid-increment handling is unchanged: it prints the API's
nullresult and exits 0. This patch fixes the library's increment result and class state, without changing CLI exit semantics.Validation
Executed on native Windows x64 with Node 24.15.0 and npm 11.12.1, against main
6e05b7637396ac66522cff8731f07cfe0ef49a29:npm test -- --reporter=terse: all 51 files and 9,357 assertions pass. Statement, branch, function and line coverage are all 100%. The command's ESLint andtemplate-oss-checkstages also pass.git diff --check: passed.No dependencies or generated tooling were changed. No matching main-component overflow issue or PR was found in pre-submission searches. Prepared with Codex assistance and reviewed independently by four Luna agents and one Sol agent. These reviews supplement the executed tests. Hosted CI and maintainer review are still pending.