Skip to content

Fix dart func_start false positives; dart now beats tree-sitter on Func Precision - #2073

Merged
squid-protocol merged 1 commit into
mainfrom
tri-comparison-validate-dart
Aug 21, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
tri-comparison-validate-dart

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Root-caused and fixed two false-positive bug classes in dart's func_start regex (the zero-prefix branch of gitgalaxy/standards/language_standards.py):
    1. Dart 3 switch-expression arms matched as getters — the bare-=> lookahead alternative was accepted unconditionally even though every real parameterless => expr in Dart requires an explicit get. Fixed by gating it behind the same get-group conditional already used for the bare-; case in this regex.
    2. Calls with a lambda argument matched as function definitions — the paren-lookahead used a naive, non-balanced-paren check (\([^)]*\)) that stopped at the lambda's own closing paren instead of the outer call's. Fixed by switching to the same balanced-paren pattern the args rule and this regex's own return-type-prefix groups already use, plus a guard rejecting Dart 3's object-destructuring pattern syntax (Pattern(:field) =>).
  • Full corpus diff (language-crucible/data/dart, 7 Flutter framework files): 126 false-positive matches removed, 1 genuine recall gain (EditableText's own multi-line constructor). Every removed match was manually spot-checked as a real false positive.
  • dart now wins Func Precision outright against tree-sitter (1732/1741 = 99.48% vs tree-sitter's 1732/1748 = 99.08%) — previously an unvalidated, asterisked disagreement with no badge.
  • Side effect: also fixes a previously-xfail'd known gap in test_dart.py (a string literal containing text that looks like a function header no longer false-positives, since the balanced-paren tracking correctly treats the embedded () as nested rather than the call's own close).
  • Validated all three open dart tri-comparison ledger shapes with concrete evidence (function existence ×2, function args). Filed dart func_start: switch-expression arms and calls-with-lambda-args false-positive-matched as function definitions #2071 for the fixed bugs (this PR closes it) and dart func_start: remaining recall/precision gaps from the switch-expression-arm sweep (#2071 follow-up) #2072 for several smaller, confirmed-but-deferred recall/precision gaps found in the same investigation — including one naive fix (excluding implements/with/extends from the return-type-prefix token vocabulary) that was tried, tested, and reverted after it broke generic method type-parameter bounds like pushNamed<T extends Object?>(...), a much more common legitimate pattern.
  • Re-blessed both golden master fixtures (full-precision and zero-dependency) to reflect the corrected dart function/class counts and their expected downstream topological/global-average ripple.

Closes #2071.

Test plan

  • tests/extraction/languages/test_dart.py + test_dart_strict.py: 196 passed, 1 skipped, 4 xfailed
  • tests/ruff_audit.py --ci / tests/mypy_audit.py --ci: no new findings
  • crucible_check.py against the full ~80-repo corpus: all 86 mismatches traced to the dart fix's direct effect or its expected topological/global-average ripple; both golden masters re-blessed
  • tri_comparison_chart.py --all --write regenerated; diff confirmed scoped to dart only (ledger's 34 newly-discovered unrelated-language entries and 146 unrelated-entry timestamp refreshes from the same full regen were deliberately excluded from this PR to keep it scoped)

🤖 Generated with Claude Code

…hapes

Root-caused two false-positive bug classes in dart's func_start regex
(zero-prefix branch): Dart 3 switch-expression arms matched as getters
(bare `=>` accepted without requiring `get`), and calls with a lambda
argument matched as function definitions (naive non-balanced-paren
lookahead landed on the lambda's own closing paren instead of the
call's). Fixed by gating the bare-arrow alternative behind the existing
`get`-group conditional and switching to the same balanced-paren
pattern already used elsewhere in this regex, plus a guard against
Dart 3's object-destructuring pattern syntax. Full corpus diff
(language-crucible/data/dart): 126 false positives removed, 1 genuine
recall gain (EditableText's own multi-line constructor).

dart now wins Func Precision outright against tree-sitter (1732/1741
vs 1732/1748) -- previously an unvalidated, asterisked disagreement.

Validated all three open dart tri-comparison ledger shapes (function
existence x2, function args) with concrete evidence; filed gitgalaxy#2071
for the fixed bugs and gitgalaxy#2072 for several smaller, confirmed-but-
deferred recall/precision gaps found in the same investigation (a naive
fix for one of them -- excluding implements/with/extends from the
return-type-prefix vocabulary -- was tested and reverted after it broke
generic method type-parameter bounds like `pushNamed<T extends Object?>`).

Re-blessed both golden master fixtures (full-precision and
zero-dependency) to reflect the corrected dart function/class counts
and their expected topological/global-average ripple, verified via
crucible_check.py against the full ~80-repo corpus.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squid-protocol
squid-protocol merged commit 9b6b8d2 into main Aug 21, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the tri-comparison-validate-dart branch August 21, 2026 22:47
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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.

dart func_start: switch-expression arms and calls-with-lambda-args false-positive-matched as function definitions

1 participant