Skip to content

dartanalyzer does not warn/error when using symbols in case expressions #21580

Closed
@mkustermann

Description

@mkustermann

The analyzer differes in behaviour from dart2js/VM. It's a compile-time error for dart2js/VM.

$ cat test.dart
main() {
  switch(#abc) {
    case #abc:
      print('abc');
      break;
    case #xyz:
      print('xyz');
      break;
  }
}

$ dartanalyzer test.dart
Analyzing [test.dart]...
No issues found

$ dart2js test.dart
test.dart:3:10:
Error: 'case' expression type 'Symbol' overrides 'operator =='.
    case #abc:
         ^^^^
Error: Compilation failed.

$ dart test.dart
'file:///usr/local/google/home/kustermann/repositories/gcloud/test.dart': error: line 3 pos 11: type class of case expression must not implement operator ==
    case #abc:
          ^

Slightly related to Issue #15445.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions