Skip to content

Doc comments in typedefs for record types can't reference field names #60332

Open
@GiancarloCante

Description

@GiancarloCante

In doc comments for typedefs that define record types, using square brackets ([ ]) to reference field names does not recognize them as in-scope identifiers. This makes it impossible to link to those fields in documentation.

This issue specifically applies to record type field names, both positional and named, when used inside a typedef.

Reproduction

/// - [a] BAD: The referenced name isn't visible in scope.
/// - [b] BAD: The referenced name isn't visible in scope.
/// - [T] GOOD: The referenced name is visible in scope.
typedef Record1<T> = (
  int a,
  String b,
);

/// - [a] BAD: The referenced name isn't visible in scope.
/// - [b] BAD: The referenced name isn't visible in scope.
/// - [T] GOOD: The referenced name is visible in scope.
typedef Record2<T> = ({
  int a,
  String b,
});

Expected behavior

The field names a and b should be treated as in-scope identifiers, and [a] and [b] should be linkable in the doc comments.

Actual behavior

  • [T] is correctly recognized and linkable.
  • [a] and [b] are not recognized, despite being valid field names in the record type alias.

Environment

  • Dart SDK 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-cliUse area-dart-cli for issues related to the 'dart' command like tool.dart-cli-doc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions