Skip to content

fix(parse): text after an invalid number run is no way out - #30

Open
lejmr wants to merge 2 commits into
conformance/upstream-pearlsfrom
fix/number-run-then-letters
Open

lejmr wants to merge 2 commits into
conformance/upstream-pearlsfrom
fix/number-run-then-letters

Conversation

@lejmr

@lejmr lejmr commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Stacked on #29 (and #28 under it); retarget to main once they are in.

unquoted-strings.13: "The initial number character, plus any valid-in-JSON number characters that follow it, must be parsed as a number value." The suite reads this as an error for a = 1.2.3 (025) and a = 1e (022). zig-hocon followed it only when nothing came after the run: 1.2.3x and an unquoted UUID were strings, as in typesafe/config and pyhocon (lightbend/config#480).

case input spec zig-hocon before Java 1.4.9, pyhocon
unquoted-strings/026 a = 1.2.3x error "1.2.3x" "1.2.3x"
unquoted-strings/027 id = 92806961-7548-48f0-943c-8fb861bb642f error the string the string

The catch is units: read strictly, 5EB and 5exabytes would be errors too (their run is 5E), and size-in-bytes-format/003–004 need them to be the number 5 and the unit. So the rule in src/utils/number.zig is: text may follow the run only when the run is a number, or a number plus one e/E that starts the unit. Consequences worth a look:

  • errors now: 1.2.3x, 01x, 2024-01-01T10, a UUID, scala = 2.13.x, and 1e5.x, which had an .ok row in src/Ast.zig (its run 1e5. is no number; the row is now .bad, with the reason)
  • unchanged: 10.0bar, 10ms, 5EB, 5exabytes, -1.5Ei, 1e+5x
  • 1ex stays a string: it is the same shape as 5exabyte

python/MIGRATING.md extends the IP-address note to UUIDs and versions, with a row in the table. Caret test in src/root.zig. zig-hocon passes all 471.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CbBo1aotFTDLY2gery7qYD

lejmr and others added 2 commits October 24, 2026 23:18
- unquoted-strings/026: `a = 1.2.3x`, the run 1.2.3 must be parsed as a number and is not one
- unquoted-strings/027: an unquoted UUID, the same (lightbend/config#480)

typesafe/config and pyhocon read both as strings (java: lenient). zig-hocon took text after the run as a way out and fails both: 469/471.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CbBo1aotFTDLY2gery7qYD
`checkNumber` let any word that starts with a digit fall back to text once something followed the run, so `1.2.3x`, `01x`, a UUID and `2.13.x` were strings. Text after the run now needs a number in front of it; a unit that starts with `e` or `E` lends the run its first letter, so `5EB` and `5exabytes` stay the number 5 and the unit (size-in-bytes-format/003–004). `1e5.x` is an error now as well: its run `1e5.` is no number.

zig-hocon passes all 471 cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CbBo1aotFTDLY2gery7qYD
@lejmr
lejmr force-pushed the conformance/upstream-pearls branch from 1fdb9b4 to 95c1622 Compare October 24, 2026 21:18
@lejmr
lejmr force-pushed the fix/number-run-then-letters branch from 967f183 to 1eceb1f Compare October 24, 2026 21:18

This branch has not been deployed

No deployments
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.

1 participant