Skip to content

Make int32 config parsing strict and loud#266

Merged
hbarthels merged 1 commit into
mainfrom
hb-int32-config-strict
Jul 13, 2026
Merged

Make int32 config parsing strict and loud#266
hbarthels merged 1 commit into
mainfrom
hb-int32-config-strict

Conversation

@hbarthels

Copy link
Copy Markdown
Contributor

Summary

_extract_value_int32 previously silently returned the field default when a config value was present but not an int32_value (e.g. a bare 2 written instead of 2i32). That silent fallback masked malformed input — the real bug was the silent failure, not strictness.

This changes the helper to error loudly (ParseError) when a config value is present with the wrong type, while:

  • keeping the i32 suffix requirement (we do not promote bare ints), and
  • returning the default only when the field is genuinely absent.

This is a fresh take on #265 addressing @comnik's review feedback: don't promote — error loudly on the wrong type.

Changes

  • meta/src/meta/grammar.y: rewrote _extract_value_int32 — absent field → default; present int32_value → return it; present anything else → builtin.error(...). Emitted as a bare statement (the builtin.error template codegens to raise/throw/panic, which is invalid in a return position).
  • Regenerated the Python, Julia, and Go parsers via make force-parsers. The bulk of the generated-file diff is temp-variable (_tNNNN) renumbering; the only logic change is _extract_value_int32. Go builds clean.
  • Regression tests (Julia parser_tests.jl, Python test_parser.py): :csv_header_row 2i32 parses (header_row == 2); a bare 2 raises ParseError; omitting the field yields the default (1).

No version bump — that goes in its own separate PR.

Testing

  • Python: 789 passed
  • Julia: 174/174 test items, 33740 assertions pass
  • Go: go test ./test/... and go build ./... pass

🤖 Generated with Claude Code

Previously `_extract_value_int32` silently returned the field default when a
config value was present but not an `int32_value` (e.g. a bare `2` instead of
`2i32`). That silent fallback masked malformed input.

Now the helper errors loudly (`ParseError`) when a config value is present with
the wrong type, while still keeping the `i32` suffix requirement and returning
the default only when the field is genuinely absent.

Edited `meta/src/meta/grammar.y` and regenerated the Python, Julia, and Go
parsers. Added regression tests in the Julia and Python SDKs covering: a
properly-typed `2i32` parses, a bare `2` raises `ParseError`, and omitting the
field yields the default (1).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hbarthels hbarthels force-pushed the hb-int32-config-strict branch from b4b9b64 to cc763b0 Compare July 11, 2026 22:58
@hbarthels hbarthels marked this pull request as draft July 11, 2026 23:02
@hbarthels hbarthels marked this pull request as ready for review July 12, 2026 19:00
@hbarthels hbarthels requested review from comnik and davidwzhao July 12, 2026 19:00
@hbarthels hbarthels merged commit 46a2ef2 into main Jul 13, 2026
5 checks passed
@hbarthels hbarthels deleted the hb-int32-config-strict branch July 13, 2026 13:33
@hbarthels hbarthels mentioned this pull request Jul 13, 2026
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.

3 participants