Skip to content

dart: plain field/local-variable declarations misdetected as function stubs #1623

Closed

Description

@squid-protocol

Summary

Plain class fields and local variables (e.g., Type identifier;) are misdetected as function stubs whenever they have a return-type-shaped prefix (alternative B in func_start regex) or a late modifier (alternative A). The regex's trailing lookahead ((?=[ \t\n]*(?:<[^>]*>[ \t\n]*)?(?:\(|=>|\{|;))) accepts a bare ; as sufficient evidence of a "stub declaration" — intended for genuinely prefixed bodyless function stubs like external void externalFunc(); — but never actually requires a (...) parameter list to have appeared. Any Type identifier; without parens matches.

Confirmed repro

Direct regex test (from activated venv with gitgalaxy installed):

>>> from gitgalaxy.standards.language_standards import LANGUAGE_DEFINITIONS
>>> rule = LANGUAGE_DEFINITIONS["dart"]["rules"]["func_start"]
>>> rule.search("  AnimationController? _backingCursorBlinkOpacityController;")
<re.Match object; ...>  # captures group 2 = '_backingCursorBlinkOpacityController'
>>> rule.search("  SelectionChangedCause cause;")
<re.Match object; ...>  # captures group 2 = 'cause'  -- local var inside method body
>>> rule.search("  late List<Element> _children;")
<re.Match object; ...>  # captures group 1 = '_children'  -- 'late' modifier

Corpus impact (confirmed via tests/tools/tree_sitter_accuracy_audit.py --lang dart):

Fix direction

Alternatives A and B's trailing lookahead must require that an actual (...) parameter list appeared somewhere in the match — only accept a bare ; terminator if the match captured a (...) somewhere, never accept modifier+ name; / returnType name; with no parens at all.

Related issues

Related to #1479's investigation of dart false positives, but distinct root cause (requires parens validation, not keyword exclusion or multi-line handling).

Labels

bug, core-engine

File location

gitgalaxy/standards/language_standards.py line ~9322-9345 (dart func_start regex, alternatives A/B trailing lookahead)

Activity

  1. added
    bug
    core-engine
    on Aug 14, 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-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions