Repository navigation
Fix #618: Strict parsing tests for zig structural signatures - #739
Merged
Merged
Conversation
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]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #518, closes #618.
Adds strict positive/negative, ambiguity-sweep, and ReDoS regression coverage in
tests/core_engine/test_language_standards_strict.pyfor all 46 non-Nonezigstructuralsignatures (60 tests). Most of zig's
@-prefixed-builtin rules already carried BUG FIX commentsfrom an earlier cross-language sweep fixing the leading-
\b-before-@trap -- notre-litigated, just covered by the positive/negative table and a dedicated confirmation test.
Real bugs found and fixed
args(Rule 11, nested-delimiter):[^)]*can't represent even one level of nesting. Zigfunction-pointer-type parameters nest constantly (
fn foo(callback: fn(i32) void) void, acommon callback-parameter idiom) -- confirmed the old pattern truncated at the first inner
). Upgraded to the one-level-nesting bounded form.test:test\s+"[^"]*"ended on", inside the shared trailing\bgroup. The characterafter a closing quote in real usage (
test "basic" {) is a space then{-- both non-word,so the shared trailing
\bnever fired. This is Zig's dominant real-world test declarationshape, 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_abortssharingreturn/unreachableis intentional double-classification;state_mutation/pointerssharing pointer-deref-assignment likewise;explicit_castsvspointersandtestvsregex_execution(both flagged in the issue) don't collide.Verification (all gates)
unrelated)
golden_crucible: real diff found (348 differences, confined to 17 real.zigfiles across 4corpus 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