Repository navigation
Fix csharp func_start: bare comma and ternary-? absorbed as return-type tokens - #2057
Merged
Merged
Conversation
…pe tokens The return-type-loop's per-token character class allowed a bare comma outside any bracket/paren, letting the walk absorb comma-separated CALL ARGUMENTS (`ref mdName,`/`SpecialType.None,` inside a multi-line call) as if they were return-type tokens, landing on the call's own target identifier as a phantom function name. A real C# return type never has a bare top-level comma outside a tuple's own parens, a generic's own angle brackets, or an array's own brackets -- moved comma-tolerance into explicit `<...>`/`[...]` single-token alternatives instead of allowing it bare. Also added `(?!\?)` at each token's start to reject a token beginning with `?`, closing a ternary operator (`\n ? expr`) being consumed as if it were a nullable-type marker (`string?`, where `?` never starts a token, only ends the preceding one). Confirmed via a full corpus diff this retroactively closes ~190 previously-unknown phantom occurrences sharing the identical root cause (this.EatToken, this.ParseXxx, _syntaxFactory.Xxx, modifiers.ToList, etc. across LanguageParser.cs, CSharpCompilation.cs, MethodCompiler.cs, and Workspace.cs) -- every one confirmed to have zero real declaration anywhere in its file, only call sites, by direct source inspection. Zero real functions lost, zero new false positives introduced (a pure-narrowing character-class change). The csharp/function/existence/agree[gitgalaxy]_vs[ctags,tree_sitter] ledger shape is now fully clean: 44/44 remaining occurrences confirmed genuine (local functions inside LanguageParser.cs's known tree-sitter parse-error cascade region), zero non-cascade false positives. Fixes #2054. Found via the tri-comparison-ledger-sweep skill's csharp pass. 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
Fixes #2054. The two specific cases from that issue (
ref mdName,inside a call-argument list, a ternary?inside a switch-expression arm) both traced to the same root cause: thefunc_startreturn-type-loop's per-token character class allowed a bare comma with no bracket/paren requirement, so a run of comma-separated call arguments could be absorbed as if they were return-type tokens, landing on the call's own target identifier as a phantom function.Fix
Moved comma-tolerance into explicit
<...>/[...]single-token alternatives (generics, arrays — tuple commas already had\([^()]{0,80}\)) instead of allowing a bare comma anywhere. Added(?!\?)at each token's start to reject a token beginning with?, closing the ternary-operator case (string?'s?ends a token, never starts one, so real nullable types are unaffected).An important note on process
My first attempt at this fix was dispatched to a Gemini/agy subagent, which implemented essentially the same regex change but hit a sandbox permission wall partway through verification and couldn't complete the corpus-level check. I re-verified independently and initially misread a large drop in one file's function count (
LanguageParser.cs: 673→474 raw DB count) as a severe regression and almost discarded the fix. On closer inspection — diffing the exact function names lost, not just the count — every single one of the ~190 total "lost" occurrences across 4 files (LanguageParser.cs,CSharpCompilation.cs,MethodCompiler.cs,Workspace.cs) is a receiver.method-shaped phantom name (this.EatToken,_syntaxFactory.TypeConstraint,modifiers.ToList,solution.Workspace.GetDocumentName, etc.) with zero real declaration anywhere in its file — confirmed by direct source inspection, not assumption. The fix generalizes much further than the 2 originally-scoped cases, which is a good thing, not a regression; I was wrong to be alarmed by the raw count alone. Re-implemented and re-verified the same fix myself from scratch after discarding the subagent's uncommitted attempt, per this repo's own standing rule about not trusting a raw number without reading the actual disputed source.Also found and fixed two unrelated environment gaps in this worktree's
.crucible_venvs/full_precision(missingpytest, then missingnetworkx/tiktoken/pandas/numpy/xgboost/pyyamlentirely) — the crucible check was silently falling back to zero-dependency-mode results while reporting "full_precision: PASS", masking real verification. Fixed both before trusting any PASS result from that venv.Verification
GetWellKnownType,this.EatToken) still don't reproduce.pytest tests/extraction/languages/test_csharp.py tests/extraction/languages/test_csharp_strict.py: 167 passed.ruff_audit.py --ci/mypy_audit.py --ci: no new findings.crucible_check.py --mode both, run with genuine full-precision dependencies present (not the silently-degraded state): PASS/PASS after re-blessing both golden masters. Diff confined to csharp, zero unrelated-language ripple.csharp/function/existence/agree[gitgalaxy]_vs[ctags,tree_sitter]ledger shape: now 44/44 occurrences confirmed genuine (cascade-region local functions), 0 non-cascade false positives remaining.Test plan