Repository navigation
fix(compiler): avoid ICE for @example with large int64 - #12085
Open
Tanvir Alam (tanvir-ux) wants to merge 1 commit into
Open
Tanvir Alam (tanvir-ux) wants to merge 1 commit into
Tanvir Alam (tanvir-ux) wants to merge 1 commit into
Conversation
@example takes valueof unknown, so numeric marshalling treats the constraint as JS-number-safe. Literals above Number.MAX_SAFE_INTEGER then hit an assert in numericValueToJs and abort compilation. Keep the value as Numeric when asNumber() returns null instead of raising an internal compiler error. Fixes microsoft#12067.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Tanvir Alam (tanvir-ux)
September 30, 2026 12:26
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The fallback can violate explicit float decorator contracts, and its returned value is not directly tested.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Fixes a compiler crash when @example receives integers exceeding JavaScript’s safe range.
Changes:
- Falls back to
Numericwhen exact number conversion fails. - Adds an
int64regression test. - Adds a compiler changelog entry.
| File | Description |
|---|---|
packages/compiler/src/core/js-marshaller.ts |
Adds numeric fallback behavior. |
packages/compiler/test/decorators/examples.test.ts |
Tests oversized int64 examples. |
.chronus/changes/fix-example-int64-precision-ice-2026-09-30.md |
Documents the fix. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+82
to
+87
| // Open-ended constraints such as `valueof unknown` (used by @example) report | ||
| // canBeANumber=true, but the literal may still exceed Number.MAX_SAFE_INTEGER. | ||
| // Fall back to Numeric instead of raising an internal compiler error. Scalars | ||
| // that require a JS number (int32, float64, ...) reject out-of-range values in | ||
| // the checker before marshalling. | ||
| return type.value; |
Comment on lines
+93
to
+97
| expect(examples).toHaveLength(1); | ||
| expect(examples[0].value.valueKind).toBe("NumericValue"); | ||
| expect((examples[0].value as { value: { toString(): string } }).value.toString()).toBe( | ||
| "123456789123456789", | ||
| ); |
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.


Why
Fixes #12067
@exampleis declared asvalueof unknown. When marshalling a numeric decorator argument against that open-ended constraint,canNumericConstraintBeJsNumberreturns true, sonumericValueToJsrequires an exact JavaScriptnumber. Literals aboveNumber.MAX_SAFE_INTEGER(common withint64) makeasNumber()returnnull, and the marshaller previously raised an internal compiler error:Repro:
Changes
numericValueToJs, if the constraint looks JS-number-safe butasNumber()still returnsnull, keep the value asNumericinstead of asserting.int32,float64, …) continue to reject out-of-range literals in the checker before marshalling.@exampleonint64aboveNumber.MAX_SAFE_INTEGERcompiles and stores theNumericValue.Tests
Notes
After this fix, OpenAPI emission may still write
example: nullfor oversized integers (same as today'sdefaultfor largeint64without@encode(string)). That is separate from the ICE;#12059/#12060cover the@encode(string)serialization path.