Skip to content

fix(csharp): extend func_start Invocation Shield to cover zero-prefix bare call statements - #1429

Merged
squid-protocol merged 3 commits into
mainfrom
fix/csharp-1418-invocation-shield
Aug 13, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
fix/csharp-1418-invocation-shield

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #1418. csharp func_start's Invocation Shield allowed a multi-line bare call statement
(no modifier, no return type, ending in a bare ;) to match as if it were a function definition
-- e.g. AccumulateExplicitInterfaceName(ref explicitInterfaceName, ref separator);, a plain call
in roslyn/LanguageParser.cs, matched 3 extra times beyond the one real definition.

Fix

Split func_start into three alternatives (mirroring #1221's dart split / #1319's rust
gating):

  • Branch A -- requires >=1 modifier. Tolerates a bare ; (real abstract/interface/partial
    declarations legitimately have no body).
  • Branch B (new) -- zero modifiers, but requires a return-type-shaped prefix. Also tolerates
    bare ; (covers interface methods like void Foo(int x); that have a return type but no
    access modifier).
  • Branch C (new) -- the true zero-prefix path. Now REQUIRES the signature to actually open a
    block ({/=>) -- this is what closes the gap, since an ordinary call statement never has a
    modifier, return type, or its own block.

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

Confirmed 3 independent ways (regex finditer, isolated single-file scan, direct corpus SQL
query): the flagship repro now matches exactly once (the real definition), down from 4.

tests/tools/tree_sitter_accuracy_audit.py --lang csharp (dedupes by name, per its own
documented scope limitation):

metric before after
found_functions 571 573
extra_functions 329 309

The real-world raw-count impact is much larger than the per-name metric shows: e.g.
roslyn/LanguageParser.cs's own Function/Method Declarations count (undeduped, from an actual
galaxyscope scan) drops from 1277 to 677 in that one file alone -- the fix eliminates hundreds
of duplicate phantom "function" entries from unshielded bare call statements throughout a large
real-world file, not just the one flagship name. This is expected, correct behavior; the golden
masters were regenerated to reflect it.

Incidental findings filed separately (not in this PR's scope)

Test plan

  • tests/extraction/languages/test_csharp.py / test_csharp_strict.py -- 158 passed (2 new
    cases: a bodyless-interface valid case, the exact bare-call repro as an invalid case)
  • tree_sitter_accuracy_audit.py --lang csharp --regenerate + --summary-table
  • crucible_check.py --mode both -- both golden masters blessed (expected drift, see above),
    re-verified clean after
  • audit_check.py --ci -- ruff/mypy/dead-key/ast-accuracy all clean, no new findings

🤖 Generated with Claude Code + Gemini (Antigravity CLI)

squid-protocol and others added 3 commits August 13, 2026 09:17
… bare call statements (#1418)

Split func_start into three alternatives (mirroring dart #1221 / rust #1319):
branch A requires >=1 modifier (tolerates a bare ';' -- real abstract/interface
declarations), branch B requires a return-type-shaped prefix with no modifier
(same tolerance, covers interface methods like `void Foo(int x);`), and the new
branch C is the true zero-prefix path -- it now requires the signature to
actually open a block (`{`/`=>`), closing the gap where an ordinary multi-line
call statement with no modifier/return-type prefix (e.g.
`AccumulateExplicitInterfaceName(ref a, ref b);`) matched as if it were a
function definition.

Confirmed via 3 independent checks (regex finditer, isolated file scan, direct
corpus SQL query): the flagship repro (roslyn/LanguageParser.cs's
AccumulateExplicitInterfaceName, previously matching 4x) now matches exactly
once, at its real definition.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Gemini 3.1 Pro <[email protected]>
…lden masters

extra_functions 329->309 in the per-name accuracy audit (which dedupes by
name); the real-world raw signature-count impact is much larger -- e.g.
roslyn/LanguageParser.cs's own Function/Method Declarations count drops
1277->677 in this file alone, since the fix eliminates hundreds of duplicate
phantom "function" rows previously created by unshielded bare call
statements, not just the flagship named repro. Cascading drift in the
global PageRank/spatial-coordinate stats across the rest of the corpus is
the expected downstream ripple of that.

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 ce7ad5a into main Aug 13, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/csharp-1418-invocation-shield branch August 13, 2026 13:34
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 func_start: Invocation Shield doesn't cover multi-line bare call statements ending in ';'

1 participant