Skip to content

fix(dart): long-param constructors not found + assert() false-positive func_start - #1538

Merged
squid-protocol merged 1 commit into
mainfrom
fix/dart-1493-long-param-search-limit
Aug 14, 2026
Merged

fix(dart): long-param constructors not found + assert() false-positive func_start#1538
squid-protocol merged 1 commit into
mainfrom
fix/dart-1493-long-param-search-limit

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #1493.

Summary

  • _slice_by_braces's dart-specific terminator-scan window was pinned to start_idx + 2000, but the scan itself starts at params_end_idx -- for constructors whose parameter list alone exceeds ~1800 chars (e.g. flutter/theme_data.dart's const ThemeData.raw({...}), ~140 lines / hundreds of required this.xxx, entries), params_end_idx landed past the window, leaving no room to find the real terminator and silently rejecting the whole match.
  • Fix: dart_search_limit = min(next_match_start, max(search_limit, params_end_idx + 200)) -- anchors extra room to params_end_idx only when needed, so every normal function keeps byte-identical behavior and only the pathological long-param case widens. (A flat params_end_idx + 2000 was tried first and empirically found to reach spurious terminators in unrelated code across other files -- see commit history in this branch.)
  • Found during verification, fixed in the same PR (same root cause, not a separate scope): assert was missing from func_start's reserved-keyword exclusion lookahead, so assert(...); could be misdetected as a function definition named assert. This was already a widespread, pre-existing false positive in the flutter corpus (hundreds of instances across framework.dart/navigator.dart/object.dart/semantics.dart) -- not introduced by this PR, just newly reachable once the search window widened enough for assert's own terminator scan to succeed instead of timing out.

Numbers (7-file flutter/dart corpus, live audit)

  • found_functions: 1096 -> 1100
  • extra_functions: 571 -> 426 (25% precision improvement, mostly from the assert fix)
  • ThemeData.raw and the unnamed factory ThemeData(...) constructor: now found.

Test plan

  • pytest tests/extraction/languages/test_dart.py tests/extraction/languages/test_dart_strict.py -- 186 passed
  • tree_sitter_accuracy_audit.py --all --ci -- clean across all 31 languages (shared-helper ripple check)
  • crucible_check.py --mode both -- PASS/PASS after blessing expected drift (theme_data.dart's function count changed materially)
  • audit_check.py --ci -- all clear
  • New regression tests: a synthetic >2000-char-param constructor, and assert(...) non-matches

🤖 Generated with Claude Code

…e func_start

#1493: _slice_by_braces's dart terminator-scan search_limit was pinned to
start_idx+2000, but the scan starts at params_end_idx -- for constructors with
parameter lists themselves exceeding ~1800 chars (e.g. ThemeData.raw's ~140-line
constructor), params_end_idx landed past the limit, leaving zero room to find the
real terminator and rejecting the whole match. Fix anchors the extra room to
params_end_idx instead, but only when it would exceed the original bound
(max(search_limit, params_end_idx+200)) -- preserves identical behavior for every
normal function and only widens for the pathological case, avoiding a file-wide
loosening that independently proved to reach spurious terminators elsewhere.

Also fixes a related false-positive found during verification: `assert` was
missing from func_start's reserved-keyword exclusion, so `assert(...);` could be
misdetected as a function definition -- already a widespread, pre-existing false
positive in flutter's corpus (hundreds of instances), not something this PR's
search_limit change introduced, just newly reachable once the window widened
enough for assert's own terminator hunt to succeed.

Net effect on the 7-file flutter/dart corpus: found_functions 1096->1100,
extra_functions 571->426 (a 25% precision improvement, mostly from the assert fix).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 7860653 into main Aug 14, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/dart-1493-long-param-search-limit branch August 14, 2026 02:36
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol added a commit that referenced this pull request Aug 14, 2026
…sequence (#1545)

PR #1539 (tcl fix) was built against main before PR #1538 (dart fix) merged,
so its own crucible-audit CI ran against a stale base and correctly flagged
drift -- but auto-merge proceeded anyway since crucible-audit isn't a required
check, landing tcl's fix without its golden masters reflecting dart's already-
merged changes. This blesses main's actual current combined state (both fixes
applied) rather than a snapshot of either fix in isolation. No code change.

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
squid-protocol added a commit that referenced this pull request Aug 14, 2026
* fix(python): args regex only balanced one level of nested parens

#1527: python's args rule's parameter-list capture group
\((?:[^()]|\([^()]*\))*\) balances exactly one level of nested parens (outer
paren + one inner non-nested group). A default value with two levels of
nested calls -- FastAPI's dependency-injection idiom
Depends(partial(callable_gen_dependency, "x")) -- doesn't match at all, so
the whole def statement is skipped and args silently defaults to 0.

Extends the existing bounded-recursion idiom by one more level (still no
unbounded backtracking -- same ReDoS-safety tradeoff already established for
this rule, just deeper). Confirmed 12 occurrences of this exact shape in
language-crucible/data/python/fastapi/tests/test_dependency_partial.py.

args_exact_match: 3588 -> 3601 (python corpus), no other metric changed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore: regenerate baselines against post-dart/tcl/bless main

Rebased this branch onto the current main (after #1538/#1539/#1545 merged)
and regenerated the target's own tree-sitter baseline, both golden masters,
and the ruff line-shift baseline against the combined state. No additional
code change beyond the previous commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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: constructors with very long (>~2000 char) parameter lists still not found (e.g. ThemeData.raw)

1 participant