Skip to content

Analyzer should trigger an error if enum comparison is used as const expression #45441

Closed
@a14n

Description

@a14n

With Dart 2.13.0 (build 2.13.0-150.0.dev) the analyzer accepts enum comparison in const expression though enum comparisons are not yet allowed in asserts.

enum E { a, b }
@immutable
class A {
  const A([E e = E.b]) : assert(e != E.a); // no diagnostic but there should be an `invalid_constant` error for `e != E.a`
}
void main() {
  const A(); // const_evaluation_throws_exception
}

/cc @scheglov @bwilkerson

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions