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

Provide hint when for-in loop is wrong #18861

Closed
bwilkerson opened this issue May 16, 2014 · 6 comments
Closed

Provide hint when for-in loop is wrong #18861

bwilkerson opened this issue May 16, 2014 · 6 comments
Assignees
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

@bwilkerson
Copy link
Member

Consider the following code:

List<String> strings = <String>[];
for (int i in strings) { }

There should be a hint that a string cannot be assigned to an int.

@lrhn
Copy link
Member

lrhn commented May 16, 2014

That seems like something that should be a warning, not a hint.
The spec fails to give a warning because it types an intermediate variable as "int", but that variable ought to be typed as the "static type of e.iterator".


cc @gbracha.

@gbracha
Copy link
Contributor

gbracha commented May 16, 2014

I agree in principle. However, I'm not sure we can tighten existing rules. This could be regarded as a breaking language change. Up for discussion.


Set owner to @gbracha.
Added Accepted label.

@srawlins
Copy link
Member

srawlins commented Jun 8, 2014

This is a dup of Issue #18534, no? good discussion over there.

@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.

@bwilkerson bwilkerson 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 accepted labels Feb 29, 2016
@munificent
Copy link
Member

This is done as of: cb7aa02

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

7 participants