Repository navigation
fix(lua): shield \z string continuation across newlines (#2437) - #2447
Merged
Merged
Conversation
Lua's `\z` escape skips the following run of whitespace INCLUDING line
breaks, so
(Message or print)('\n >>> testC not active: skipping tests for \z
userdata <<<\n')
is one single-quoted string spanning two physical lines. The lua branch
of `_apply_literal_shield` bounds its quote patterns by newline (so an
unterminated single-line quote can't swallow the file), so this string
never matched -- leaking the word `for` as live code, which
`_slice_by_keywords` counted as a `\bfor\b` Mode-D opener with no `end`.
The `if not T then` above it then ran to EOF as one
`Anonymous_Block_[Truncated]` satellite (events.lua).
Fixed by adding `\z[ \t\r\n]*` as an explicit cross-newline alternative
to lua's `standard_double` / `standard_single` shield patterns. Plain
`\<newline>` continuation was already covered by `\\.` under re.DOTALL;
only `\z` + trailing whitespace needed handling. `\z` appears in 6 corpus
files (`main.lua` even has `function () \z` inside a string); only
events.lua currently desynced, the rest were latent.
Measured (`tree_sitter_accuracy_audit.py --lang lua`): extra_functions
1 -> 0, function precision 99.8% -> 100.0%. Both golden masters re-blessed
(events.lua + main.lua metric shifts + topological ripple), lua baseline +
summary table regenerated, ledger verdicts + chart + points-of-interest
regenerated (`--all`), `docs/language_status/lua.md` §9 updated.
This is #2437's last lua repro. The issue's other half -- a mid-file
blast-radius containment heuristic -- is deliberately not built: no
remaining repro to validate it against, and fixing desync sources (6/6
this sweep) has consistently beaten adding containment backstops. Two
low-value recall misses remain in the ledger (`constructs.lua:f`
occurrence-alignment fuzz, `literals.lua:lexerror` in the Lua suite's
lexer-torture fixture), documented not chased.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S
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.
Hardens the last remaining lua repro of #2437.
Root cause
Lua's
\zescape skips the following run of whitespace including line breaks, sois one single-quoted string spanning two physical lines. The lua branch of
_apply_literal_shieldbounds its quote patterns by newline (so an unterminated single-linequote can't swallow the file), so this string never matched — leaking the word
foras livecode, which
_slice_by_keywordscounted as a\bfor\bMode-D opener with noend. Theif not T thenabove it then ran to EOF as oneAnonymous_Block_[Truncated]satellite(
events.lua).Fix
Add
\z[ \t\r\n]*as an explicit cross-newline alternative to lua'sstandard_double/standard_singleshield patterns. Plain\<newline>continuation was already covered by\\.under
re.DOTALL; only\z+ trailing whitespace needed handling.\zappears in 6 corpusfiles (
main.luaeven hasfunction () \zinside a string) — onlyevents.luacurrentlydesynced, the rest were latent.
Measured
tree_sitter_accuracy_audit.py --lang lua:extra_functions1 → 0, function precision99.8% → 100.0%.
found_functionsunchanged at 618 (the truncated satellite was never a realfunction).
Differential Scan
events.lua+main.luametric shifts (the\zstrings arenow correctly shielded) + topological ripple.
crucible_check.py --mode bothPASS.--all --ci(both audits) OK.--all --write).docs/language_status/lua.md§9 updated.audit_check.pyclean; lua extraction + strict + detector + prism tests pass.Scope
The issue's other half — a mid-file blast-radius containment heuristic — is deliberately not
built. After this fix there is no remaining corpus repro to validate it against, and fixing
desync sources (6/6 defects across this sweep) has consistently beaten adding containment
backstops. I'd recommend closing #2437.
Two low-value recall misses remain in the ledger (
constructs.lua:foccurrence-alignment fuzz ona 4×-redefined name;
literals.lua:lexerrorin the Lua suite's lexer-torture fixture) —documented in §5, not chased.
🤖 Generated with Claude Code
https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S