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

Improve the error message for assignment to final local variables #30490

Closed
bwilkerson opened this issue Aug 18, 2017 · 1 comment
Closed

Improve the error message for assignment to final local variables #30490

bwilkerson opened this issue Aug 18, 2017 · 1 comment
Labels
analyzer-ux 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-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@bwilkerson
Copy link
Member

Given the following code:

main() {
  final x = 0;
  x = 42;
}

Analyzer produces an error message that discusses the absence of a setter, but local variables do not induce getters and setters, so the error is confusing.

@bwilkerson bwilkerson added analyzer-ux 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-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Aug 18, 2017
@srawlins
Copy link
Member

srawlins commented Jun 8, 2020

The analyzer now produces a much more readable error:

  error • The final variable 'x' can only be set once. • 30490.dart:3:3 • assignment_to_final_local
  hint • The value of the local variable 'x' isn't used. • 30490.dart:2:9 • unused_local_variable

@srawlins srawlins closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux 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-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants