Repository navigation
fix(dart): 4 func_start false-positive shapes (const ctors, bodyless ctors, class-header continuations, list-element calls) - #1494
Merged
Conversation
…ctors, class-header continuations, list-element calls)
func_start was under- and over-matching real dart constructs in four distinct ways:
1. `const ClassName.name(...)` named constructors were unconditionally excluded by
the regex's blanket const-precedes-name lookahead. Narrowed to only exclude
`const IDENT =`/`const IDENT;` (variable declarations), letting `const IDENT(`/
`const IDENT.IDENT(` (constructor calls) through.
2. Colon-initializer, no-braced-body constructors (`Ctor(...) : super.x();`) fell
through to whatever brace happened to come next, merging with the following
method and losing the real name to detector.py's "Unknown_Block" fallback.
Added a dart-specific paren/bracket/angle-depth-aware terminator scan that
recognizes `:` as starting an initializer list and correctly treats a
following `;` as the real (bodyless) end -- including when the initializer
list itself has multiple comma-separated initializers (`: a = b, assert(c);`,
Dart's normal multi-initializer syntax), which a first attempt at this fix
mishandled by reusing the same comma-terminated scanner used for bug 4 below.
3. Multi-line class header continuation lines (`implements X {` / `extends Y<T> {`
on their own line) misfired as func_start matches. Excluded via a leading
negative lookahead for `implements`/`with`/`extends` as the first token.
4. Multi-line bare call-site invocations used as list-literal elements
(`ContextMenuButtonItem(\n ...,\n),`) still slipped past the existing
Invocation Shield. The same terminator scan now rejects a match whose
parameter list is immediately followed by a top-level `,`.
found_functions 705->819, real_functions 705->884 (recall 79.8%->92.6%).
extra_functions rose slightly (281->286) -- verified the 5 new "extra" names
(e.g. ErrorWidget.withDetails, TextEditingController.fromValue) are real
constructors GitGalaxy now correctly finds that the accuracy tool's own
tree-sitter ground truth doesn't yet resolve a name for (same class of gap
#1477 partially closed) -- not new false positives.
Fixes #1479.
Co-authored-by: Claude Sonnet 5 <[email protected]>
squid-protocol
enabled auto-merge (squash)
August 13, 2026 20:43
…art-false-positives # Conflicts: # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json
…landed first) Parallel-PR conflict on the machine-generated golden master files -- resolved per the documented pattern (checkout --theirs, then regenerate fresh on the merged code rather than hand-resolving JSON conflicts). crucible_check.py --mode both confirmed PASS/PASS after regenerating. 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 #1479 -- four distinct, confirmed
func_startfalse-positive/false-negative shapes in dart:const ClassName.name(...)named constructors excluded entirely. The regex's blanketconst-precedes-name exclusion (guarding againstconst x = value;) also blocked the legitimate constructor shape. Narrowed to only excludeconst IDENT =/const IDENT;, lettingconst IDENT(/const IDENT.IDENT(through.Ctor(...) : super.x();) confused the brace-slicer into merging with the next method, losing the real name todetector.py's"Unknown_Block"fallback. Added a dart-specific paren/bracket/angle-depth-aware terminator scan recognizing:as an initializer list, terminated correctly by a following bodyless;-- including when the initializer list has multiple comma-separated initializers (: a = b, assert(c);), which is normal Dart syntax and which an earlier version of this fix mishandled (see note below).implements X {/extends Y<T> {on their own line) misfired as func_start. Excluded via a leading negative lookahead.,.Measured:
found_functions705->819,real_functions705->884 (recall 79.8%->92.6%).A note on process (independent verification caught a real bug in the first pass)
The Gemini/agy dispatch's first implementation of bug 2's fix reused the same terminator scanner for both the params-end check (which must stop at a top-level
,, needed for bug 4) and the colon-initializer-list scan (which must NOT -- Dart constructors routinely have multiple comma-separated initializers at depth 0, e.g.flutter/theme_data.dart's realThemeData.raw:}) : b1 = x, b2 = y, assert(z);). That version silently rejected every multi-initializer constructor, including the actual repro case bug 1 was meant to fix. Caught during independent re-verification (theThemeData.rawrepro from the issue was still showing as "missing" post-fix), root-caused, and fixed directly by giving the initializer-list scan its own comma-skipping pass rather than reusing the comma-terminated one. Added a dedicated regression test (test_dart_slicer_multi_initializer_constructor) covering both the bodyless and body-bearing multi-initializer shapes.extra_functions note
extra_functionsrose slightly (281->286) as a side effect of finding more real constructors. Verified all 5 new "extra" names by hand against the real corpus (e.g.ErrorWidget.withDetailsatflutter/framework.dart:5632,TextEditingController.fromValueatflutter/editable_text.dart:251) -- every one is a real dart constructor GitGalaxy now correctly extracts, which the accuracy tool's own tree-sitter ground truth (partially fixed by #1477/PR #1478) still doesn't resolve a matching name for in every shape. Not new false positives -- the audit tool's--regenerateregression gate correctly flagged this rise and required manual override with this explanation, per its own instructions.One remaining gap filed separately as #1493 (not fixed here, out of scope): constructors with pathologically long parameter lists (hundreds of lines, e.g.
ThemeData.rawitself) still aren't found, due to an unrelatedsearch_limitbound in_slice_by_bracesbeing too tight relative to the params-search's own larger lookahead budget.Test plan
tests/extraction/languages/test_dart.py(regex-level valid/invalid cases for all 4 bugs, plus dedicated slicer-level teststest_dart_slicer_bug_2_and_4andtest_dart_slicer_multi_initializer_constructor)pytest tests/extraction/languages/test_dart.py tests/extraction/languages/test_dart_strict.py-- 183 passedtree_sitter_accuracy_audit.py --lang dart --regenerate(manually applied after independently verifying the extra_functions rise was legitimate, per the tool's own "explain in the PR description" instruction),--summary-tableregenerated--all --ciclean across all 31 languagescrucible_check.py --mode both-- real drift confirmed as intended (e.g.flutter/events.dart's Public Exports count rose from finding more real constructors), blessed via--update --yes, re-ran to confirm PASS/PASSaudit_check.py --ci-- caught 2 real B023 (ruff) findings from the nested terminator-scan closing over per-iteration loop variables (safe_code/search_limit); fixed by binding them as function defaults rather than suppressing, then re-verified clean