You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(json): preserve -0 sign and stop panicking on lone-surrogate strings
Two parser bugs found by adversarial QuickCheck testing:
- #4049: parse aborted (panic, not ParseError) on strings that mix a
raw lone trailing surrogate with any escape sequence, e.g. the
5-code-unit text " U+DC00 \n ": lex_string_slow's flush sliced with
the checked ctx.input[start:end], which aborts when the code unit at
a boundary is a trailing surrogate. Use view(start_offset~,
end_offset~) (bounds checks only), matching the fast path in
lex_string, so such strings parse successfully instead of crashing
the process.
- #4053: parse("-0") returned +0.0 while parse("-0.0") / parse("-0e0")
returned -0.0: the integer fast path in lex_number_end negated the
mantissa as an Int64 (where -0 == 0) before converting to Double.
Negate after the conversion so every spelling of negative zero keeps
the IEEE-754 sign bit, per RFC 8259 number semantics.
Both fixes are backend-independent (wasm-gc, js, native) and covered by
deterministic regression tests in lex_string_test.mbt and
lex_number_test.mbt.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments