Navigation Menu

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

Hint: For Loop var should not be field #16660

Closed
DartBot opened this issue Feb 9, 2014 · 6 comments
Closed

Hint: For Loop var should not be field #16660

DartBot opened this issue Feb 9, 2014 · 6 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package 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 Feb 9, 2014

This issue was originally filed by kbeck...@gmail.com


What steps will reproduce the problem?

  1. create fields: var id="Hello"; var list=["Blubb"];
  2. have a loop: for (id in list){}
  3. notice that id is now "Blubb"

What is the expected output? What do you see instead?
The code works as programmed. It however is questionable whether any reasonable developer would ever want to write such code. It is more likely that this may happen by accident. It should produce an error, unless I am missing some really important use-case.
This becomes even more annoying when it is used in for example a polymer element where you are not directly seeing id in your code..

What version of the product are you using? On what operating system?
Dart Editor version 1.2.0.dev_03_02 (DEV)
Dart SDK version 1.2.0-dev.3.2

@lrhn
Copy link
Member

lrhn commented Feb 10, 2014

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Aug 26, 2014

I sympathize. The traditional for loop is a relic that we have tried to stay close to, and we probably should not. Mainly this is supposed to ease porting, but how much code that is ported relies on this misfeature? That said, it is now a breaking change. Perhaps the editor could give a hint; it's just another case of shadowing, and some notice of shadowing has been discussed for a very long time.

Reclassifying as an editor feature request.


Removed Area-Language label.
Added Area-Editor label.

@sethladd
Copy link
Contributor

Removed Area-Editor label.
Added Area-Analyzer label.
Changed the title to: "Hint: For Loop var should not be field".

@bwilkerson
Copy link
Member

Removed Priority-Unassigned label.
Added Priority-Medium, Analyzer-Hint labels.

@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 27, 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

Sounds like this could have false positives, when people rely on this "feature." Maybe an "analyzer-linter" instead?

@bwilkerson bwilkerson added analyzer-linter Issues with the analyzer's support for the linter package and removed analyzer-warning Issues with the analyzer's Warning codes labels Apr 20, 2016
@pq
Copy link
Member

pq commented Jan 21, 2019

A broader version of this hint is under discussion in dart-lang/linter#597. Feel free to nudge!

@pq pq closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package 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

8 participants