Skip to content

Attempting to use a type with type arguments as a constant produces too many diagnostics #35997

Closed
@scheglov

Description

@scheglov
main() {
  const v = List<int>;
}

Results in the following errors when I run:

bin/test.dart:2:21: Error: An equality expression can't be an operand of another equality expression.
Try re-writing the expression.
  const v = List<int>;
                    ^
bin/test.dart:2:22: Error: Expected an identifier, but got ';'.
  const v = List<int>;
                     ^
bin/test.dart:2:17: Error: The method '<' isn't defined for the class 'Type'.
 - 'Type' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named '<'.
  const v = List<int>;
                ^

However I'd expect this to work, because 16.2 Constants says that type arguments are allowed:
image

@danrubel

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestimprove-diagnosticsRelated to the quality of diagnostic messageslegacy-area-front-endLegacy: Use area-dart-model instead.model-error-recoveryError recovery in analyzer/CFE.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions