Analyzer fails Language/03_Overview/1_Scoping_A02_t30 and t31 #3474
Labels
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Milestone
This issue was originally filed by zundel@google.com
The expectation is that a static warning is emitted when the variable declaration overrides the type. That part works. But there is also a compile time error in trying to use an identifier that represents a variable as a type:
Here's the code:
typedef func();
main() {
var func = 1;
checkTypeError( () {
func f = () => null; //'func' can't be used as a type in this scope.
});
}
Analyzer output:
$ dart_analyzer ./tests/co19/src/Language/03_Overview/1_Scoping_A02_t30.dart
file:/home/zundel/dart-all/dart/tests/co19/src/Language/03_Overview/1_Scoping_A02_t30.dart:21: Local variable 'func' is hiding 'FUNCTION_TYPE_ALIAS func' at <unknown>:func:0:0
20: main() {
21: var func = 1;
file:/home/zundel/dart-all/dart/tests/co19/src/Language/03_Overview/1_Scoping_A02_t30.dart:23: type "func" expected, but "VARIABLE" found
22: checkTypeError( () {
23: func f = () => null; //'func' can't be used as a type in this scope.
Compilation failed with 1 problem.
In spec version 0.10 13.2 there is an explicit example:
var i;
i j;
...
that is supposed to have a static type warning in this case in the declaration of j. The error from the analyzer is a compile-time error.
The text was updated successfully, but these errors were encountered: