Implementations allow void as type of getters. #17650
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
The specification allows "void" as the return type of top-level non-external getters only, not any other getter.
It is a syntax error to have "void" as a return type of non-top-level or non-external getters - the grammar does not allow it.
Implementations (VM, dart2js and analyzer) all allow void as a getter return type. Example code:
void get x => null;
//external void get y;
class C {
void get x => null;
static void get y => null;
}
main() {
C.y;
new C().x;
x;
// y;
}
This runs and analyzes without errors in the VM, dart2js and the analyzer. If removing the comments for the external getter, it still runs in the and analyzer, and parses in the VM and dart2js.
Should we change the specification?
Should void be allowed as a type in other places too?
Or is this a widespread implementation bug?
Should void be allowed for top-level non-external getters?
The text was updated successfully, but these errors were encountered: