Skip to content

Enhanced enums: incorrect missing case clause analyzer warning #49188

@olof-dev

Description

@olof-dev

The analyzer raises the warning missing_enum_constant_in_switch for the code below, saying Missing case clause for 'data' and similarly for moreData. Of course, they shouldn't have case clauses.

enum E {
  a, b;
  
  static final data = "I'm not a real enum member";
  static const moreData = 'Neither am I';
  
  String get name {
    switch(this) {
      case a:
        return 'AAAA';
      case b:
        return 'BBBB';
    }
  }
}

(Dart SDK version: 2.17.1 (stable))

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failureslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions