-
Notifications
You must be signed in to change notification settings - Fork 2k
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
loop variables also global if name in global #643
Comments
Here's a patch that forces loop parameters to declare themselves in the closest possible scope: http://github.com/jashkenas/coffee-script/commit/fa95f743f31a614635c4e93e16c23f7bdd8693e3 I'm afraid that it doesn't fix 100% of the cases, because if there's no difference in scope between the variable and the loop, it'll still override it -- that's simply JavaScript's behavior that we aren't going to change... But it does fix your case, and others that are similar to it. |
I think it will be good enough, because re-using the same variable locally is asking for trouble, and is at least somewhat obvious. great work; for me coffeescript is officially the most productive language |
I ran into this with something like: There's nothing to be done for that? |
Actually, the issue's plain to see right on the CoffeeScript splash page: |
Looks like this change was a mistake ... looking at reverting. |
Looks perfectly normal, but does not work!
The question is, should the
for rule in rules
makerule
a local? I doubt the current behavior is expected. Just spend an hour debugging same issue, but just a lot less obvious ...I know this is related to the issue 238 that I raised earlier: http://github.com/jashkenas/coffee-script/issues/issue/238 .
However this one is even less obvious. And if we would rewrite it:
It would work. Nobody expects the
for rule in rules
to be different I guess?The text was updated successfully, but these errors were encountered: