Repository navigation
Fix enum exponentiation folding at the int64 boundary - #65716
Open
Anders Hejlsberg (ahejlsberg) wants to merge 4 commits into
Open
Anders Hejlsberg (ahejlsberg) wants to merge 4 commits into
Anders Hejlsberg (ahejlsberg) wants to merge 4 commits into
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Anders Hejlsberg (ahejlsberg)
marked this pull request as ready for review
November 28, 2026 17:29
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the numeric constant-evaluation boundary fix.
No open issues 🎉
What changed in this PR
Fixes #65703 by preventing the compiler’s numeric constant evaluator from converting 2 ** 63 to an out-of-range int64, which caused incorrect negative enum values.
Changes:
- Makes the exact-integer exponentiation path’s upper bounds exclusive while preserving
-2 ** 63as a valid base. - Adds boundary regression tests and baselines covering JavaScript emit, declaration emit, types, and symbols.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/enumExponentiationInt64Boundary.ts |
Adds enum cases for boundary values, odd/even exponents, and a negative base. |
tsc/testdata/baselines/reference/compiler/enumExponentiationInt64Boundary.types |
Records expected types for the regression cases. |
tsc/testdata/baselines/reference/compiler/enumExponentiationInt64Boundary.symbols |
Records expected enum symbols. |
tsc/testdata/baselines/reference/compiler/enumExponentiationInt64Boundary.js |
Records corrected JavaScript and declaration output. |
tsc/internal/jsnum/jsnum.go |
Excludes 2 ** 63 from integer-conversion bounds. |
tsc/internal/jsnum/jsnum_test.go |
Adds exact numeric expectations at and below the boundary. |
Review effort: Balanced
This branch has not been deployed
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.
TypeScript 7 can fold
(2 ** 63) ** 3in an enum to a negative value because the positive base is converted to an out-of-rangeint64.2 ** 63from the exact-integer exponentiation path; preserve-2 ** 63as a valid endpoint.(2 ** 63) ** 3in an enum to a negative value #65703