Repository navigation
Conversation
…uption Integer-valued numbers with magnitude >= 1e21 were tagged <integer> and serialized via Number.prototype.toString(), which uses exponential notation for such values (e.g. "1e+21"). On parse, the <integer> branch uses parseInt(value, 10), which stops at the "e" and returns 1, silently dropping 21+ orders of magnitude with no error. Classify a number as <integer> only when Number.isInteger(next) and Math.abs(next) < 1e21; otherwise emit <real>. The <real> parse branch uses parseFloat, which recovers "1e+21" exactly. Values below 1e21 are unaffected. The binary plist path already round-trips these values correctly, confirming this is an XML-text serialization defect rather than a representational limit.
|
@spokodev is attempting to deploy a commit to the TooTallNate's Team Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 01f9ffb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
Integer-valued numbers with magnitude
>= 1e21are silently corrupted on abuild->parseround-trip.No error is thrown, so callers have no signal that 21+ orders of magnitude were lost.
Cause
buildclassifies any integer-valued number as<integer>and serializes it withNumber.prototype.toString():For
|x| >= 1e21,toString()returns exponential notation, e.g.(1e21).toString() === "1e+21", producing<integer>1e+21</integer>. On parse, the<integer>branch doesparseInt(value, 10), which stops at theeand returns1.The boundary is exactly
1e21: values below it (including1e20and562341325190349060000) stringify in plain decimal and round-trip fine. The binary path (buildBinary/parseBinary) round-trips1e21correctly, so this is an XML-text serialization defect, not a representational limit.Apple's PLIST DTD defines
<integer>and<real>as the two numeric element types; a value that cannot be expressed as a plain-decimal integer string belongs in<real>.Fix
Classify a number as
<integer>only when it is a true integer below the exponential threshold; otherwise emit<real>:The
<real>parse branch already usesparseFloat, which recovers1e+21exactly. Values below1e21keep the existing<integer>output, so there is no behavior change for the common case.Test
Added a round-trip test under
parse() > integer. It fails onmaster(expected 1 to be 1e+21) and passes with the fix. Full suite: 113 passing.Note
src/build.browser.ts(line ~76) has the same classification logic and the same defect. I scoped this PR to the Node path that the repro exercises; let me know if you want the browser build fixed in this PR or a follow-up.