Skip to content

[analyzer] Please improve error message for enum constructor tear-off #61680

@sgrekhov

Description

@sgrekhov

The code below produces an error but the error message reported by the analyzer is unclear.

enum E<T> {
  e0.id(1);

  final int v;
  const E.id(this.v);
}

main() {
  print(E.id); // Analyzer: Generative enum constructors can only be used as targets of redirection. Try using an enum value, or factory constructor. • invalid_reference_to_generative_enum_constructor
}

An error message reported by CFE is much clearer. It is "Error: Enum constructors can't be torn off.". Please update the analyzer's error message for enum constructor tear-off.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.improve-diagnosticsRelated to the quality of diagnostic messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions