Skip to content

Complex destructing assignments make wrong code #2613

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

Closed
LunaBorowska opened this issue Nov 13, 2012 · 2 comments
Closed

Complex destructing assignments make wrong code #2613

LunaBorowska opened this issue Nov 13, 2012 · 2 comments

Comments

@LunaBorowska
Copy link

This returns 1 (properly):

a = {}
[a.b] = [1, 2, 3]
console.log a.b

This is generated code:

(function() {
  var a;
  a = {};
  a.b = [1, 2, 3][0];
  console.log(a.b);
}).call(this);

This returns undefined:

a = {}
[(a).b] = [1, 2, 3]
console.log a.b

And generated code:

(function() {
  var a, _base;
  a = {};
  // _base.b? Shouldn't it be 0?
  (_base = a).b = [1, 2, 3][_base.b];
  console.log(a.b);
}).call(this);

It seems to work in REPL, but it doesn't in other places.

@vendethiel
Copy link
Collaborator

[a.b] = [1, 2, 3]

@jashkenas
Copy link
Owner

That first example looks correct to me, but the second one was certainly a bug. Should be fixed now.

jashkenas added a commit that referenced this issue Feb 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants