Skip to content

Support Parsers 2 and 3 for number parsing; parse typed integers exactly under allownan - #480

Merged
quinnj merged 6 commits into
masterfrom
codex/parsers-3-number-migration
Sep 5, 2026
Merged

Support Parsers 2 and 3 for number parsing; parse typed integers exactly under allownan#480
quinnj merged 6 commits into
masterfrom
codex/parsers-3-number-migration

Conversation

@quinnj

@quinnj quinnj commented Aug 20, 2026

Copy link
Copy Markdown
Member

JSON.jl can now load with Parsers 3. It also fixes #478: requested integer fields under allownan=true no longer pass through Float64, so typemax(Int64) and values above 2^53 stay 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-sized BigInt values.

Untyped numbers under allownan=true still return Float64. 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 allownan regression tests.

Co-authored by Codex

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.30%. Comparing base (2907192) to head (9da7baf).

Files with missing lines Patch % Lines
src/lazy.jl 97.55% 6 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj
quinnj force-pushed the codex/parsers-3-number-migration branch 2 times, most recently from 5892ca6 to 6368b27 Compare September 4, 2026 06:08
@quinnj quinnj changed the title Use Parsers 3 kernels for number parsing Support Parsers 2 and 3 for number parsing; parse typed integers exactly under allownan Sep 4, 2026
…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>
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.
@quinnj
quinnj merged commit 766455e into master Sep 5, 2026
12 checks passed
@quinnj
quinnj deleted the codex/parsers-3-number-migration branch September 5, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inexact Error when parsing using typemax(Int) and allownan=true

1 participant