Skip to content

enums should be allowed in constant expressions #29278

@Hixie

Description

@Hixie

It's common in Flutter code to use enums heavily. Since these are always entirely known at compile time, it is unfortunate that they cannot be used in constant expressions. (Constant expressions with enums would allow us to assert things about arguments based on enums in constant constructors which would allow big performance wins in widget trees which could be constant in principle but can't today because of this issue.)

enum X { a, b }
const bool foo = X.a == X.b; // <-- won't compile
void main() {
  print(foo);
}

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).core-ltype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions