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

Incorrect assignement behaviour in 'let' to 'for' loop variable #423

Closed
susano opened this issue Nov 23, 2013 · 4 comments · Fixed by #434
Closed

Incorrect assignement behaviour in 'let' to 'for' loop variable #423

susano opened this issue Nov 23, 2013 · 4 comments · Fixed by #434

Comments

@susano
Copy link

susano commented Nov 23, 2013

One would expect x to be 42, like y at that point of the program.

for x in [10]
  y = 10
  let
    x := 42
    y := 42
  console.log("x : #x") # => 10
  console.log("y : #y") # => 42
@vendethiel
Copy link
Contributor

Should we remove auto-infusing IIFEs ?

Just FTR, this comes from Coco, when we didn't have for let, you'd just be able to capture loop vars doing

for x in [10] then let
 qS "#el-#{x}" .onclick = -> alert x

I don't think this feature is heavily used and we can probably remove it now that we have saud for let.
Thoughts ?

@robotlolita
Copy link
Contributor

Any reason why x is even captured in this code?

var i$, ref$, len$, x, y;
for (i$ = 0, len$ = (ref$ = [10]).length; i$ < len$; ++i$) {
  x = ref$[i$];
  y = 10;
  (fn$.call(this, x));
  console.log("x : " + x);
  console.log("y : " + y);
}
function fn$(x){
  x = 42;
  y = 42;
}

@vendethiel
Copy link
Contributor

As I said, it's called Auto-infusing IIFEs and was used to auto-capture loop vars with let.

@robotlolita
Copy link
Contributor

I see, yeah, I don't think that feature is really needed with for let, and it makes things weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants