Skip to content

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

Closed

Description

@squid-protocol

Summary

Found while independently verifying #1418 (csharp func_start Invocation Shield fix) -- a
separate, pre-existing false-positive class, confirmed NOT a regression from #1418 (reproduces
identically against the pre-#1418 regex too, since that path had no prefix requirement at all).

detector.py's own ; vs {/=> terminator shield (added for #789, around line 2016) can be
fooled by a lambda's => appearing inside a multi-line call statement's arguments, before the
statement's real terminating ;. This is a distinct mechanism from #1418's regex-level fix
(which operates in language_standards.py) -- a second, independent place csharp's "is this a
real function body-open or just an ordinary statement" judgment can go wrong.

Repro

language-crucible/data/csharp/roslyn/CSharpCompilation.cs (approximate shape, confirmed via a
minimal standalone repro file):

ReportManifestResourceDuplicates(
    moduleBuilder.ManifestResources,
    SourceAssembly.Modules.Skip(1).Select(m => m.Name),   // <-- this `=>` fools the shield
    AddedModulesResourceNames(resourceDiagnostics),
    resourceDiagnostics);

detector.py's shield finds the => inside .Select(m => m.Name) before the statement's real
terminating ;, and treats it as if it were an expression-bodied member's own arrow -- misreports
SourceAssembly.Modules.Skip as a function name.

Suggested fix shape

The shield needs to track paren/bracket depth (similar to how #1319's rust bodyless-declaration
handling tracks [/] depth to avoid a ; inside an attribute being mistaken for a statement
terminator) so an => found while still inside an unclosed argument-list paren doesn't count as
the statement's own arrow. Located in gitgalaxy/core/detector.py, the ;/{/=> terminator
logic around line 2016-2046.

Scope note

This only affects func_start/args/class_start name-extraction accuracy (the extraction-
gauntlet pillar from epic #813), not GitGalaxy's risk-scoring rules, which are unaffected.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-positive
    priority: low
    on Aug 13, 2026
  2. added this to the v2.4.8 milestone on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginepriority: lowtestingthreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions