sdk
sdk copied to clipboard
Confusing analyzer error message when naming variable the name of a type
Take this code:
final int int = 7;
void main() {
final num num = 7;
}
This results in a strange error:
error • int isn't a type at 22553.dart:1:7 • not_a_type
error • Local variable 'num' can't be referenced before it is declared at 22553.dart:4:9 • referenced_before_declaration
The second error makes sense, sort of. But in the first error, the message is bogus.
Just verified that it still behaviors that way.
It would be better to say something like "The type '{0}' can't be used here because it's shadowed by the variable name.", and to use the same message in both cases.