Skip to content

Analyzer fails Language/03_Overview/1_Scoping_A02_t30 and t31 #3474

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions