Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DartBot opened this issue Jun 8, 2012 · 4 comments
Closed

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

DartBot opened this issue Jun 8, 2012 · 4 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Milestone

Comments

@DartBot
Copy link

DartBot commented Jun 8, 2012

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.

@bwilkerson
Copy link
Member

Added this to the M1 milestone.

@DartBot
Copy link
Author

DartBot commented Jun 26, 2012

This comment was originally written by [email protected]


Set owner to [email protected].

@DartBot
Copy link
Author

DartBot commented Jun 27, 2012

This comment was originally written by [email protected]


https://chromiumcodereview.appspot.com/10699005


Added Started label.

@DartBot
Copy link
Author

DartBot commented Jun 27, 2012

This comment was originally written by [email protected]


r9171


Added Fixed label.

@DartBot DartBot added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Jun 27, 2012
@DartBot DartBot added this to the M1 milestone Jun 27, 2012
copybara-service bot pushed a commit that referenced this issue Aug 11, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/e8d00c0..5cfb1f3):
  5cfb1f36  2023-08-07  Sam Rawlins  Bump to analyzer 6.1.0 (#3474)

ffi (https://github.com/dart-lang/ffi/compare/f01dfca..e2c01a9):
  e2c01a9  2023-08-08  Slava Egorov  Expose pointer to free from allocators (#203)

http (https://github.com/dart-lang/http/compare/7e9ed12..9f167a7):
  9f167a7  2023-08-08  Alex James  Remove example test from java_http (#1001)

test (https://github.com/dart-lang/test/compare/5d571d6..9b1828f):
  9b1828f4  2023-08-09  Nate Bosch  Send a MessagePort to host on frame startup (#2072)
  ae2ab1ee  2023-08-08  Jacob MacDonald  publish test_core v0.5.6 (#2076)
  2e9bba21  2023-08-08  Jacob MacDonald  fix failing casts when talking to minified apps from the host (#2075)

tools (https://github.com/dart-lang/tools/compare/f14bf2e..295ff92):
  295ff92  2023-08-10  Elias Yishak  Fix empty string for `CLIENT_ID` from being sent when user decides to opt in (#144)
  bc6c9f0  2023-08-09  Elias Yishak  Clean up on dart docs across all dart files under lib (#142)

Change-Id: I75147259ce51f240c1dc359896ec7709bada288f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319783
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Daco Harkes <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

2 participants