sdk
sdk copied to clipboard
Front end: Confusing error message for void as superclass
Consider the following program:
class C extends void {}
void main() {}
With dart from commit 61f5e8845433088b7eca22c8f3cce4fa10acccd2 we get the following errors:
n062.dart:1:17: Error: Type 'void' can't be used here.
Try removing 'void' keyword or replace it with 'var', 'final', or a type.
class C extends void {}
^^^^
n062.dart:1:17: Error: Type 'void' not found.
class C extends void {}
^^^^
This is confusing, given that void is used as a superclass and that is an error, but we can't say var or final in that position. Also, not found is a surprise.
implements void gets a similar treatment.
The analyzer produces two diagnostics:
- "Expected a type name."
- "Classes can only extend other classes."
For the 'implements' case the first diagnostic is the same, but the second is tailored to it being an implements clause.
There really only needs to be one diagnostic here, and the second is better (especially since void is a type).