Repository navigation
fix(dart/core): preserve large numbers in formatString - #4196
Open
leoafarias wants to merge 1 commit into
Open
leoafarias wants to merge 1 commit into
leoafarias wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes an issue in formatString where whole doubles outside the signed 64-bit range were being clamped. It updates _numberToString and _normalizeNumbers in function_support.dart to ensure that only integral doubles within the signed 64-bit range are converted to integers, while larger values remain as doubles to prevent clamping. Additionally, comprehensive tests have been added to verify this behavior across various large number boundaries and structures. I have no further feedback to provide.
Collaborator
|
Hi @leoafarias, thank you for raising this PR and we verified that it fixes large number formatting in formatString. |
1 task done
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.
Description
Fixes #4193.
formatStringprinted whole numbers of 2^63 or more as9223372036854775807on the Dart VM and Wasm._numberToStringand_normalizeNumberscalltoInt(), which clamps to the 64-bit limits, and_normalizeNumbershas no range check at all.Solution
toInt()only for whole doubles in[-2^63, 2^63).1e20prints100000000000000000000. Inside a list or map the value stays a double, sojsonEncodewrites[100000000000000000000.0], the right number with a.0._normalizeNumbersdoc comment anddart/a2ui_core/CHANGELOG.md.Verification
dart/a2ui_core/test/basic_catalog_test.dart: bare, list and object values around both 64-bit limits and1e21, plus1e300and-1e300. 26 of them fail onmain.dart testindart/a2ui_corepasses (2,398 tests), and so dodart analyze --fatal-infosandscripts/fix_format.sh --check.Pre-launch Checklist
One time:
For this PR:
I haven't run a sample or
scripts/e2e_test.sh: both need an agent backed by a live model and an API key I don't have set up here.If you need help, consider asking for advice on the discussion board.