Skip to content

fix(csharp): make Invocation Shield terminator scan paren/bracket-depth aware - #1454

Merged
squid-protocol merged 1 commit into
mainfrom
fix/csharp-1428-lambda-arrow-shield
Aug 13, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/csharp-1428-lambda-arrow-shield

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #1428 (follow-up to #1418). csharp's ; vs {/=> terminator shield in detector.py did
three independent .find() calls and picked whichever came first by raw string index, with no
awareness of paren/bracket nesting -- a lambda argument's => inside a multi-line call's unclosed
parens could arrive before the statement's real terminating ;, misreporting the call's own
identifier as a function.

Fix

Replaced the three .find() calls with a single forward scan tracking ()/[] depth, only
treating {, ;, or => as a real terminator at depth 0 -- same idiom as rust/zig/dart's
existing depth-aware terminator scans. Gated entirely to lang_id == "csharp".

Root-caused by Claude, implemented by Gemini (agy/Antigravity CLI) in an isolated worktree,
independently re-verified end-to-end by Claude before push.

Results

extra_functions 309 -> 308 -- SourceAssembly.Modules.Skip (the issue's repro) confirmed gone
from the false-positive sample; no other metric moved.

Test plan

  • tests/extraction/languages/test_csharp.py / test_csharp_strict.py -- 159 passed (new
    regression test instantiates StructuralExtractor directly on the repro snippet)
  • tree_sitter_accuracy_audit.py --lang csharp --regenerate + --summary-table
  • tree_sitter_accuracy_audit.py --all --ci -- all 31 languages clean
  • crucible_check.py --mode both -- both golden masters blessed (expected small drift),
    re-verified clean after
  • audit_check.py --ci --regenerate -- ruff/mypy/dead-key/ast-accuracy all clean

🤖 Generated with Claude Code + Gemini (Antigravity CLI)

…th aware (#1428)

The `;` vs `{`/`=>` terminator shield (added for #789) did three
independent `.find()` calls and picked whichever came first by raw string
index, with no awareness of paren/bracket nesting. A lambda argument's
`=>` inside a multi-line call's unclosed parens (e.g.
`.Select(m => m.Name)`) could arrive before the statement's real
terminating `;`, so the shield misread an ordinary statement as an
expression-bodied member.

Replaced the three .find() calls with a single forward scan that tracks
()/[] depth and only treats {, ;, or => as a real terminator at depth 0 --
same idiom as rust/zig/dart's existing depth-aware terminator scans.

extra_functions 309->308 (SourceAssembly.Modules.Skip confirmed gone from
the false-positive sample).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Gemini 3.1 Pro <[email protected]>
@squid-protocol
squid-protocol merged commit 77d2f11 into main Aug 13, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/csharp-1428-lambda-arrow-shield branch August 13, 2026 15:55
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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.

csharp: detector.py's ';' vs '{'/'=>' terminator shield is fooled by a lambda arrow inside multi-line call arguments

1 participant