sdk
sdk copied to clipboard
[Augmentations] No error when augmenting enum has no values
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
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.
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() {
}
}