Support Parsers 2 and 3 for number parsing; parse typed integers exactly under allownan - #480
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #480 +/- ##
==========================================
+ Coverage 89.99% 91.30% +1.31%
==========================================
Files 7 7
Lines 1519 1679 +160
==========================================
+ Hits 1367 1533 +166
+ Misses 152 146 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
quinnj
force-pushed
the
codex/parsers-3-number-migration
branch
2 times, most recently
from
September 4, 2026 06:08
5892ca6 to
6368b27
Compare
…tly under allownan Parsers 3 removed xparse2/Options, so JSON.jl could not load against it. JSON now validates the number token against the JSON grammar itself (scannumber), which also accumulates the Int64 value, and hands the span to a small backend surface selected at load time: the Parsers 3 kernels (parsefloat/parsebigint/parsenext) or the existing Parsers 2 xparse2 calls. Drops Parsers 1; requires Julia 1.10. parsenumber receives the requested type, so a concrete integer target parses the digits exactly instead of through Float64 (fixes #478). Untyped parsing with allownan=true still returns Float64 for every number. Adds a Parsers 2 CI lane. Tests for the long-mantissa float bugs are gated on Parsers >= 2.8.8, which will carry the fix for Parsers 2 users. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
quinnj
force-pushed
the
codex/parsers-3-number-migration
branch
from
September 4, 2026 06:16
6368b27 to
97d0e01
Compare
quinnj
marked this pull request as ready for review
September 4, 2026 15:59
Parse decimal and exponent forms for requested integer types without an intermediate Float64 conversion. Preserve Float64 output for untyped allownan array values, require the first compatible Parsers 2 release, and test that exact floor in CI.
Accumulate common fixed-width decimal and exponent tokens in UInt128, bound exponent expansion before multiplication, and reserve BigInt for long coefficients that can shrink to fit. Exclude BigInt targets from exponent expansion to prevent small inputs from forcing very large allocations.
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.
JSON.jl can now load with Parsers 3. It also fixes #478: requested integer fields under
allownan=trueno longer pass throughFloat64, sotypemax(Int64)and values above2^53stay exact.The number parser supports Parsers 2.8.8 and 3. Digit-only integers use the integer path. Requested fixed-width integer types through 128 bits also convert decimal and exponent forms exactly under
allownan=true. The conversion bounds the exponent and retained coefficient before arithmetic. Oversized inputs take linear scan work without constructing input-sizedBigIntvalues.Untyped numbers under
allownan=truestill returnFloat64. Non-integer targets retain the float path, including the sign of-0. Configured special values keep precedence. Parsers 2.8.8 supplies the required long-mantissa and signed-zero fixes.The release version is 1.8.0. The Julia minimum is now 1.10, and Parsers 1 is no longer supported. Parsers 2 remains supported for downstream compatibility.
Validation includes the original file round trip, signed and unsigned limits through 128 bits, decimal/exponent forms, byte buffers, nested arrays, invalid grammar, configured specials, and large coefficients/exponents. Local full suites pass with Parsers 2.8.8 and 3.0.0. Generated checks cover another 12,000 exact-integer cases per backend. The 10 KB resource probes allocate 48–112 bytes.
CI explicitly pins each backend. The trim test uses the same Parsers version as its parent test. The temporary single-thread workaround was removed because InlineStrings 1.4.6 now supports Parsers 3.
Supersedes #479. Thanks @Kiwy3 for the original typed
allownanregression tests.Co-authored by Codex