Summary
Dart's func_start regex treats a multi-line annotation whose arguments span several lines --
@Deprecated('...' '...',) is the corpus example -- as part of the following declaration's
return-type prefix, so the match spans from @Deprecated( through the real declaration name.
>>> fs.finditer(" @Deprecated(\n 'Use ... '\n 'This feature was deprecated ...',\n )\n const ToolbarOptions({\n ...")
match: " @Deprecated(\n 'Use ... '\n 'This feature ...',\n )\n const ToolbarOptions"
groups: (None, None, None, 'ToolbarOptions', None, None, None) span: (0, 139)
Downstream, _count_top_level_args (or the args regex) then finds the annotation's own
(...) first and counts its arguments instead of the real parameter list.
Confirmed impact
The last 6 entries of dart/function/args/agree[none]_vs[gitgalaxy,tree_sitter] after #2309's
three other fixes, all this one shape:
| file:line |
symbol |
gg args |
ts args (correct) |
| editable_text.dart:405 |
ToolbarOptions (const ctor) |
0 |
4 |
| framework.dart:7017 |
RootRenderObjectElement (ctor) |
0 |
1 |
| semantics.dart:1105 |
flags (getter) |
1 |
0 |
| semantics.dart:6301 |
isFocusable (getter) |
1 |
0 |
| object.dart:1372 |
debugOutstandingSemanticsHandles (getter) |
1 |
0 |
| theme_data.dart:1460 |
buttonBarTheme (getter) |
1 |
0 |
Each has a multi-line @Deprecated(\n '...'\n '...',\n) immediately above it.
Note
Single-line annotations (@Annotation('test'), already covered by test_dart_func_start_valid)
are fine -- the return-type-prefix consumption only wanders when the annotation's argument list
carries a newline and a top-level comma. A naive "don't let the prefix cross a )" fix is
risky: the prior #2308/#2309 investigation found the prefix scan legitimately needs to cross
> for generic method type-parameter bounds, and #2311 deliberately left extends out of an
implements/with fix for the same ambiguity -- so this needs the same regression discipline
(crucible_check + the tree-sitter args baseline) as those.
Found via #2309 / the dart tri-comparison args exploration.
Summary
Dart's
func_startregex treats a multi-line annotation whose arguments span several lines --@Deprecated('...' '...',)is the corpus example -- as part of the following declaration'sreturn-type prefix, so the match spans from
@Deprecated(through the real declaration name.Downstream,
_count_top_level_args(or theargsregex) then finds the annotation's own(...)first and counts its arguments instead of the real parameter list.Confirmed impact
The last 6 entries of
dart/function/args/agree[none]_vs[gitgalaxy,tree_sitter]after #2309'sthree other fixes, all this one shape:
ToolbarOptions(const ctor)RootRenderObjectElement(ctor)flags(getter)isFocusable(getter)debugOutstandingSemanticsHandles(getter)buttonBarTheme(getter)Each has a multi-line
@Deprecated(\n '...'\n '...',\n)immediately above it.Note
Single-line annotations (
@Annotation('test'), already covered bytest_dart_func_start_valid)are fine -- the return-type-prefix consumption only wanders when the annotation's argument list
carries a newline and a top-level comma. A naive "don't let the prefix cross a
)" fix isrisky: the prior #2308/#2309 investigation found the prefix scan legitimately needs to cross
>for generic method type-parameter bounds, and #2311 deliberately leftextendsout of animplements/withfix for the same ambiguity -- so this needs the same regression discipline(
crucible_check+ the tree-sitter args baseline) as those.Found via #2309 / the dart tri-comparison args exploration.