sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[Augmentations] No error when augmenting enum has no values

Open sgrekhov opened this issue 1 year ago • 1 comments

The code below produce no expected error in the analyzer.

enum E1 {
  e0;
}

augment enum E1 {}
//           ^^
// [analyzer] unspecified
// [cfe] unspecified

But enum without any values must be a syntax error (even it is an augmenting declaration).

Appropriate failing co19 test https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmenting_enum_values_A03_t04.dart

sgrekhov avatar Oct 11 '24 07:10 sgrekhov

Yes, I'd expect a syntax error for that, too. I'm not aware of any grammar updates that would allow for the list of <enumEntry> terms to be empty.

eernstg avatar Oct 11 '24 08:10 eernstg

using augment to add a method to an enum like so:

augment enum E1 {
  void mymethod() {
  }
}

DOES trigger an Expected an identifier error and you must put in an empty enum entry list to resolve it:

Following works (adding closing semicolon for entry list):

augment enum E1 {
  ;                                         <<<< empty empty entry list FIXES ERROR
  void mymethod() {
  }
}

timmaffett avatar Feb 04 '25 02:02 timmaffett