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

Add option to the analyzer (also in Editor) that specifies to assume that the keyword "var" is a type inferred specifier #17945

Closed
DartBot opened this issue Apr 1, 2014 · 6 comments
Labels
analyzer-warning Issues with the analyzer's Warning codes 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

@DartBot
Copy link

DartBot commented Apr 1, 2014

This issue was originally filed by andrew.m...@gmail.com


Add option to the analyzer (also in Editor) that specifies to assume that the keyword in an type inferred specifier.

Sample code and explanation.

void main() {
  var i = 0;
  i = "";
}

Option turned off (current behavior):
No warrning, because "var" is dynamic type alias.

Option turned on.
Warning: "A value of type 'String' cannot be assigned to a variable of type 'int'".

@bwilkerson
Copy link
Member

Added this to the Later milestone.
Removed Type-Defect, Priority-Unassigned labels.
Added Type-Enhancement, Priority-Medium, Area-Analyzer, Analyzer-Hint, Triaged labels.
Changed the title to: "Add option to the analyzer (also in Editor) that specifies to assume that the keyword "var" is a type inferred specifier".

@DartBot
Copy link
Author

DartBot commented Jun 9, 2014

This comment was originally written by @Andersmholmgren


And on final too

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@srawlins
Copy link
Member

This is implemented as a strong mode warning.

$ cat 17945.dart
void main() {
  var i = 0;
  i = "";
}

$ dartanalyzer --strong 17945.dart
Analyzing [17945.dart]...
[error] Type check failed: "" (String) is not of type int (/Users/srawlins/code/17945.dart, line 3, col 7)
[warning] A value of type 'String' cannot be assigned to a variable of type 'int' (/Users/srawlins/code/17945.dart, line 3, col 7)
[hint] The value of the local variable 'i' is not used (/Users/srawlins/code/17945.dart, line 2, col 7)
1 error, 1 warning and 1 hint found.

@bwilkerson
Copy link
Member

Hence, the flag is named --strong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes 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

5 participants