Skip to content

dart func_start consumes a multi-line @Deprecated(...) annotation as a return-type prefix, poisoning args count #2341

Closed

Description

@squid-protocol

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.

Activity

  1. added
    bug
    core-engine
    on Aug 27, 2026
  2. added this to the v2.4.9 milestone on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions