Repository navigation
Support exact literal and bounded decimal numeric conversion - #605
Open
CaelmBleidd wants to merge 1 commit into
Open
CaelmBleidd wants to merge 1 commit into
CaelmBleidd 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.
Numeric conversions such as
Number("42")and unary+valuefor a bounded multi-character string stopped at the StringToNumber limitation even when their values were directly representable.Fold immutable literal strings with the ECMAScript StringNumericLiteral grammar and binary64 rounding, rejecting Java-only numeric suffixes, hexadecimal floats, and non-ECMAScript whitespace. Symbolic strings use a guarded UTF-16 integer parser: optional sign, ECMAScript trim, at most 15 decimal digits and 32 already bounded code units. Integer accumulation uses bit-vectors and one binary64 conversion rather than execution branches per character. Empty strings, sign-only NaN, negative zero, and nullish alternatives retain their distinct values.
Other symbolic formats and larger strings remain explicit unsupported paths with their ordinary siblings retained. Existing configured string/array bounds are unchanged. The old unsupported fixtures used literal
"42"; they now use ordinary object ToPrimitive to keep testing the same unsupported/sibling contracts. A new low-level conditional test checks that both the numeric and literal-string alternatives convert exactly.Depends on #559 for the common runtime reference contracts; this PR adds only conversion code and relevant regression updates.
Validation: 27 focused tests passed with zero failures or skips (6 new source/native/parser tests, 12 conditional-value tests, 9 runtime-boundary tests). Strict TS main/test lint passes with zero issues. Reverting the conversion callers to their exact parent reproduces the source literal conversion failure; restoring the change passes. The unused parsing helpers/shared whitespace predicate remain present during that fail-before check. Full suites are left to CI; corpus coverage/performance will be measured on the combined runtime.