Skip to content

Resolve C# local functions by lexical scope - #5206

Merged
Widthdom merged 3 commits into
mainfrom
fix-issue5188
Aug 27, 2026
Merged

Resolve C# local functions by lexical scope#5206
Widthdom merged 3 commits into
mainfrom
fix-issue5188

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • resolve same-name C# local functions by their nearest complete lexical block and enclosing callable instead of treating the whole file as one family
  • preserve declaration-order visibility, overload families, method groups, nested blocks, lambdas, top-level statements, and conservative incomplete-range behavior
  • let parameter/local delegate values shadow local functions, keep unrelated scopes and files out of the graph, and carry the same identity through references, callers, inspect, impact, selectors, and LSP navigation
  • refresh existing C# indexes through bumped extractor and reference-identity contracts

Validation

  • make lint
  • dotnet build CodeIndex.sln -c Release --no-restore --nologo (0 warnings, 0 errors)
  • dotnet run --project tools/CodeIndex.Changelog -- check
  • focused Resolve C# local functions and shadowing parameters by lexical scope #5188/Preserve innermost callable containment for C# calls, local functions, and lambdas #4840 and contract tests: 14 passed on both .NET 8 and .NET 9
  • LSP suite: 128 passed on both .NET 8 and .NET 9
  • DB/reference graph suite: 1,048 passed on .NET 8; 1,047 passed and 1 skipped on .NET 9
  • full Release suite: 11,985 passed / 9 skipped on .NET 8 and 11,501 passed / 430 skipped on .NET 9; the sole failure on each framework exposed the Razor event-binding regression from the new local-function exclusion path, which was fixed and rerun together with the feature suite (7 passed on each framework)
  • self-indexed the committed HEAD; workspace freshness, graph, reference graph, C# contracts, fold, SQL graph, and file-issue checks are current with zero extraction cap hits

Adversarial review

  • Codex pass 1 found three issues: cross-file generic fallback to a local function, LSP fallback through explicit value shadowing, and returned method groups misclassified as local declarations. All were fixed with regression coverage.
  • Codex pass 2 found three issues: zero-candidate LSP suppression without explicit negative evidence, lexical overload method-group leakage, and top-level local functions escaping their file. All were fixed with graph and LSP regression coverage.

Documentation and changelog

  • updated the bilingual developer and testing guides for the lexical-resolution contract and regression coverage
  • added changelog.d/unreleased/5188.fixed.md

Follow-ups

  • None.

Fixes #5188

@Widthdom
Widthdom merged commit f57081c into main Aug 27, 2026
11 checks passed
@Widthdom
Widthdom deleted the fix-issue5188 branch August 27, 2026 01:52
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.

Resolve C# local functions and shadowing parameters by lexical scope

1 participant