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

Unfortunate error recovery for final variable declaration with missing variable names #28191

Open
leafpetersen opened this issue Dec 22, 2016 · 0 comments
Labels
analyzer-recovery area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@leafpetersen
Copy link
Member

From user feedback. Consider this code:

void test() {
  final double x;
  final double y;
  final double = 4.0;
}

The user is in the middle of editing or adding the variable name for the last line (or has forgotten to add the variable), but the error messages they see are the following:

[error] Local variable 'double' can't be referenced before it is declared. (/Users/leafp/tmp/test.dart, line 2, col 9)
[error] Local variable 'double' can't be referenced before it is declared. (/Users/leafp/tmp/test.dart, line 3, col 9)

This is confusing, and with lots of these variables in scope, the error messages are very noisy in the interim (even if the user correctly identifies the problem).

I wonder if at least in the IDE, errors that arise from using a local variable as a type could be recognized, collapsed, and a hint generated pointing to the place where the "type as local variable" is declared? Perhaps only doing this when the local variable is a type name in the enclosing scope?

cc @Hixie

@leafpetersen leafpetersen added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug labels Dec 22, 2016
@bwilkerson bwilkerson added analyzer-recovery P2 A bug or feature request we're likely to work on labels Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-recovery area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants