Skip to content

dart func_start: remaining recall/precision gaps from the switch-expression-arm sweep (#2071 follow-up) #2072

Description

@squid-protocol

Context

Follow-up from #2071 (which fixed the two largest dart func_start false-positive bug classes:
switch-expression arms and naive non-balanced-paren matching on calls-with-lambda-arguments).
After that fix, a full corpus name-diff (language-crucible/data/dart, via
tri_comparison_gatherer.gather_language("dart")) still shows 12 missing_from_gg (recall gaps)
and 6 extra_in_gg (remaining false positives) across the 7-file Flutter corpus. None of these are
individually as high-impact as #2071's fixes, and at least one (the class-header case) has a
proven-unsafe naive fix, so they're better tracked here than rushed.

Confirmed distinct root causes (not yet fixed)

  1. Multi-line class headers with with/implements clauses spanning several lines get absorbed
    as a phantom function's return-type prefix.
    Example:

    class EditableTextState extends State<EditableText>
        with
            AutomaticKeepAliveClientMixin<EditableText>,
            WidgetsBindingObserver,
            TickerProviderStateMixin<EditableText>,
            TextSelectionDelegate,
            TextInputClient
        implements AutofillClient {   // <- matched as a function named "AutofillClient"

    Do not fix this by adding implements/with/extends to the return-type-prefix
    keyword-exclusion lists
    — tried in the same investigation and confirmed to break a much more
    common, legitimate pattern: generic method type-parameter bounds, e.g.
    static Future<T?> pushNamed<T extends Object?>(...) in flutter/navigator.dart:1902 (and ~15
    other methods in the same file), which also uses extends. A corpus-wide regression check
    showed the naive fix cost more real matches than it gained. A real fix needs to distinguish
    "extends inside a <...> generic-bound context" from "extends/implements/with as a bare
    class-header continuation token", which the current regex has no mechanism for.

  2. Ternary-expression : conflated with a constructor initializer-list :. Example
    (flutter/object.dart:2814):

    (targetFrameMatch != null && targetFrameMatch.groupCount > 0)
        ? targetFrameMatch.group(1)
        : ...

    targetFrameMatch.group(1) matches as a call (correctly reaches its own real closing paren via
    the dart func_start: switch-expression arms and calls-with-lambda-args false-positive-matched as function definitions #2071 balanced-paren fix), but the following ternary : satisfies the same lookahead
    alternative meant for constructor initializer lists (Foo(int x) : y = x {), producing a false
    positive. Also seen: _RestorationInformation.named(...) (flutter/navigator.dart, several
    call sites) and nodeToEnsureGeometry.toList()..sort(...) (flutter/object.dart:1586, a
    cascade-operator chain) — need individual root-causing, may or may not share this exact
    mechanism.

  3. EditableText's own constructor regex-matches but doesn't reach the final pipeline output.
    Confirmed via direct regex probe: func_start.finditer() DOES match EditableText({ at
    flutter/editable_text.dart:829 (this was itself a dart func_start: switch-expression arms and calls-with-lambda-args false-positive-matched as function definitions #2071 bonus fix — previously didn't match at
    all). But tri_comparison_gatherer.gather_language("dart")'s post-pipeline gg_funcs list still
    doesn't contain it. This points to a detector.py-level extraction/naming bug downstream of the
    regex, not a regex problem — needs tracing through the actual pipeline (see
    how_to_investigate_a_discrepancy.md's step 2b guidance), not just the raw regex.

  4. Static getters with a dotted (prefixed-import) return type never match at all. Example
    (flutter/editable_text.dart:2076):

    static ui.BoxHeightStyle get defaultSelectionHeightStyle {

    Root cause: the return-type-prefix character class ([\w<>\[\],?], used ~4 times in this
    regex) doesn't include ., so a qualified type name like ui.BoxHeightStyle can't be consumed
    as a single return-type token (there's no whitespace between ui, ., and BoxHeightStyle for
    the token-separator [ \t\n]+ to anchor on). The regex's own NAME-capture group already handles
    dotted names ((?:[a-zA-Z_]\w*\.)?[a-zA-Z_]\w*) — extending the same allowance to the
    return-type charclass is the likely fix, but needs its own regression check (added . could
    have knock-on effects at branch boundaries) before shipping, same discipline as the "extends"
    near-miss above.

  5. Private named constructors with an empty/underscore-only name (ClassName._(...)) and
    bodyless default constructors (ClassName();) regex-match but reach different fates.

    _DiscreteKeyFrameSimulation._(this._keyFrames, this.maxDuration) at
    flutter/editable_text.dart:535 regex-matches (confirmed via probe) but is missing from the
    final pipeline output — likely the same class of bug as item 3. _EditableTextTapOutsideAction();
    (bodyless, flutter/editable_text.dart:6706) doesn't match the raw regex at all — a distinct
    recall gap, possibly related to the existing bodyless-constructor handling that other languages
    already solved (rust rust func_start misses bodyless multi-line trait method signatures (deserialize_* family) #1319, objc objective-c: bodyless C-style prototypes are only found by accident, with a wrong body span #1336) but dart may not fully mirror.

  6. Several remaining missing_from_gg names not yet individually traced: recorder
    (flutter/object.dart), ChildSemanticsConfigurationsResultBuilder, OrdinalSortKey,
    SemanticsData, SemanticsProperties (flutter/semantics.dart), extension
    (flutter/theme_data.dart) — flagged for the next investigation pass, not yet root-caused.

Scope note

None of these are individually as high-leverage as #2071's fixes (each affects a handful of
occurrences, not ~126), and item 1 in particular needs a fundamentally different mechanism than a
keyword-exclusion list to fix safely. Good candidates for a future harden-language-extraction
pass on dart, or a follow-on tri-comparison-ledger-sweep dispatch once the ledger's dart shapes
reproduce again after #2071 lands.

🤖 Filed with Claude Code

Activity

  1. added
    bug
    core-engine
    threat: false-negative
    threat: false-positive
    on Aug 26, 2026
  2. squid-protocol commented on Aug 27, 2026

    @squid-protocol
    OwnerAuthor

    Re-verified against current main (2026-08-26) as part of a tri-comparison-ledger-sweep scoped to dart: PR #2129's fix only covered items 3 and 4 (dotted return-type charclass, colon-initializer 200-char length cap). Items 1, 2, 5, and 6 were never actually fixed, so this issue was closed as COMPLETED prematurely. Re-filed the still-open scope, re-confirmed with fresh regex tests and a fresh gather_language("dart") diff, as #2308. The separate args-counting defect this issue's item shape overlaps with (constructor param counts reading 0 under a generic-bounded class header) never had its own issue at all — filed as #2309.

  3. added this to the v2.4.9 milestone on Aug 31, 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-enginethreat: false-negativethreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions