Skip to content

Fix #618: Strict parsing tests for zig structural signatures - #739

Merged
squid-protocol merged 1 commit into
mainfrom
fix/618-zig-strict-parsing-v1
Jul 29, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/618-zig-strict-parsing-v1

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Part of #518, closes #618.

Adds strict positive/negative, ambiguity-sweep, and ReDoS regression coverage in
tests/core_engine/test_language_standards_strict.py for all 46 non-None zig structural
signatures (60 tests). Most of zig's @-prefixed-builtin rules already carried BUG FIX comments
from an earlier cross-language sweep fixing the leading-\b-before-@ trap -- not
re-litigated, just covered by the positive/negative table and a dedicated confirmation test.

Real bugs found and fixed

  1. args (Rule 11, nested-delimiter): [^)]* can't represent even one level of nesting. Zig
    function-pointer-type parameters nest constantly (fn foo(callback: fn(i32) void) void, a
    common callback-parameter idiom) -- confirmed the old pattern truncated at the first inner
    ). Upgraded to the one-level-nesting bounded form.
  2. test: test\s+"[^"]*" ended on ", inside the shared trailing \b group. The character
    after a closing quote in real usage (test "basic" {) is a space then { -- both non-word,
    so the shared trailing \b never fired. This is Zig's dominant real-world test declaration
    shape, not an edge case -- only the named-identifier form ever matched.

Both independently verified: old-pattern-reproduces / new-pattern-fixes.

Also empirically confirmed (not just asserted) three ambiguity findings: structural_boundaries/
panics_and_aborts sharing return/unreachable is intentional double-classification;
state_mutation/pointers sharing pointer-deref-assignment likewise; explicit_casts vs
pointers and test vs regex_execution (both flagged in the issue) don't collide.

Verification (all gates)

  • Strict test file: 1603 passed
  • Full default suite: 2545 passed, 1 deselected, 1 xfailed -- no regressions
  • ruff/mypy/dead-key audits clean (3 pre-existing, non-deterministic mypy findings confirmed
    unrelated)
  • golden_crucible: real diff found (348 differences, confined to 17 real .zig files across 4
    corpus repos, matching the two fixes' intent -- confirmed via direct golden_diff.deep_compare(),
    not the truncated test message). Fixtures regenerated and re-verified clean in both venvs.

🤖 Generated with Claude Code

Adds strict positive/negative, ambiguity-sweep, and ReDoS regression
coverage in tests/core_engine/test_language_standards_strict.py for all 46
non-None zig structural signatures (60 tests). Most of zig's @-prefixed-
builtin rules already carried BUG FIX comments from an earlier
cross-language sweep fixing the leading-\b-before-@ trap -- not
re-litigated, just covered by the positive/negative table and a dedicated
confirmation test like any other already-correct rule.

Found and fixed 2 real bugs:

1. `args` (Rule 11, nested-delimiter): `[^)]*` is a flat negated class,
   can't represent even one level of nesting. Zig function-pointer-type
   parameters nest constantly (`fn foo(callback: fn(i32) void) void`, a
   common callback-parameter idiom) -- confirmed the old pattern truncated
   at the first *inner* `)` instead of the true closing one. Upgraded to
   the one-level-nesting bounded form.

2. `test`: `test\s+"[^"]*"` ended on `"`, inside the shared trailing `\b`
   group. The character after a closing quote in real usage (`test "basic"
   {`) is a space then `{` -- both non-word, so the shared trailing `\b`
   never fired. This is Zig's *dominant* real-world test declaration shape
   (a quoted description), not an edge case -- confirmed only the
   named-identifier form (`test my_test {`) ever matched. Pulled out with
   no trailing `\b` (self-delimiting on the closing quote).

Both independently verified: old-pattern-reproduces / new-pattern-fixes.

Also confirmed via empirical checks (not just asserted): `structural_boundaries`/
`panics_and_aborts` sharing `return`/`unreachable` is intentional double-
classification (a return/unreachable genuinely interrupts straight-line
execution AND forcefully ends the current context); `state_mutation`/
`pointers` sharing pointer-deref-assignment is likewise intentional;
`explicit_casts` vs `pointers` and `test` vs `regex_execution` (both flagged
in the issue) don't collide -- structurally distinct token shapes.

Verification: strict test file (1603 passed), full default suite (2545
passed, 1 deselected, 1 xfailed, no regressions), ruff/mypy/dead-key audits
clean (3 pre-existing, non-deterministic mypy findings confirmed
unrelated), golden_crucible: real diff found (348 differences, confined to
17 real .zig files across 4 corpus repos, matching the two fixes' intent --
confirmed via direct golden_diff.deep_compare(), not the truncated test
message). Fixtures regenerated and re-verified clean in both venvs.

Part of #518, closes #618.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit dce2a74 into main Jul 29, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/618-zig-strict-parsing-v1 branch July 29, 2026 13:58
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.

Strict parsing tests: zig structural signatures

1 participant