sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[analyzer] Wrong error for an enum with non-final external variable

Open sgrekhov opened this issue 1 year ago • 0 comments

Not a final external variable in an enum produces an error in the analyzer but no issue in CFE.

enum E {
  e0;
  external String instanceVariable; // Enums can only declare final fields. Try making the field final.
}

extension type ET(int id) {
  external String instanceVariable; // Ok, no error
}

An external variable declaration is equivalent to an external getter declaration, and if not final, also an external setter declaration. So, there should be no such error in the analyzer.

Dart SDK version: 3.6.0-149.0.dev (dev) (Wed Aug 14 11:51:04 2024 -0700) on "windows_x64"

sgrekhov avatar Aug 21 '24 11:08 sgrekhov