Skip to content

fix(testing): dart param count now recurses into optional_formal_parameters - #1592

Merged
squid-protocol merged 1 commit into
mainfrom
fix/1570-dart-optional-formal-parameters-count
Aug 14, 2026
Merged

fix(testing): dart param count now recurses into optional_formal_parameters#1592
squid-protocol merged 1 commit into
mainfrom
fix/1570-dart-optional-formal-parameters-count

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • _get_param_count's dart handling only scanned DIRECT children of a parameter list for "formal_parameter" nodes, but tree-sitter-dart wraps BOTH optional-positional ([bool x = true]) and named ({required this.x}) parameters one level deeper, inside a shared "optional_formal_parameters" node type (confirmed identical for both bracket styles). Since named parameters are the dominant convention in idiomatic Dart/Flutter (virtually every widget constructor), any signature using either form measured 0 real params regardless of its true arity.
  • Two separate call sites needed the fix: the dart-specific function_signature branch (methods/local functions), and the generic field-based counted_types loop (constructor_signature, which — unlike function_signature — DOES expose a field-tagged "parameters" and so takes that path instead).
  • dart: args_exact_match 871 → 960 (out of 1108 comparable).

Fixes #1570

Test plan

  • Verified both code paths directly (constructor with named params, method with optional-positional params, plain required params, zero-arg) against tree_sitter_language_pack
  • python tests/tools/tree_sitter_accuracy_audit.py --lang dart — baseline regenerated, numbers above
  • python tests/tools/tree_sitter_accuracy_audit.py --all --ci — all 31 languages pass

🤖 Generated with Claude Code

…meters

_get_param_count's dart handling only scanned DIRECT children of a
parameter list for "formal_parameter" nodes, but tree-sitter-dart wraps
BOTH optional-positional (`[bool x = true]`) and named (`{required
this.x}`) parameters one level deeper, inside a shared
"optional_formal_parameters" node type -- confirmed identical for both
bracket styles. Since named parameters are the dominant convention in
idiomatic Dart/Flutter (virtually every widget constructor), any
signature using either form measured 0 real params regardless of its
true arity.

Two separate call sites needed the fix: the dart-specific
`function_signature` branch (methods/local functions), and the generic
field-based `counted_types` loop (`constructor_signature`, which --
unlike function_signature -- DOES expose a field-tagged "parameters"
and so takes that path instead).

dart: args_exact_match 871 -> 960 (out of 1108 comparable).

Fixes #1570

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 38b5dd4 into main Aug 14, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/1570-dart-optional-formal-parameters-count branch August 14, 2026 14:50
@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

1 participant