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 behaviour with array destructuring #151

Closed
dsblv opened this issue Sep 9, 2016 · 0 comments
Closed

Incorrect behaviour with array destructuring #151

dsblv opened this issue Sep 9, 2016 · 0 comments
Labels
bug Confirmed bug

Comments

@dsblv
Copy link

dsblv commented Sep 9, 2016

Babili seems to be misinterpreting array destructuring inside function bodies:

Input

const me = lyfe => {
  const [swag] = lyfe;
  return swag;
}

Output

const me=a=>{return a};

REPL

As you can see, it acts as if there's no destructuring going on at all.

It fails if you try to get more than one item:

Input

const me = lyfe => {
  const [swag, yolo] = lyfe;

  return swag && yolo;
}

Error message

repl: NodePath has been removed so is read-only. (This is an error on an internal node. Probably an internal error)

REPL

On the other hand, destructuring outside functions seems to be fine. Object destructuring also worked for me.

@hzoo hzoo added the bug Confirmed bug label Sep 9, 2016
boopathi added a commit that referenced this issue Sep 11, 2016
+ Bail out for replacement of single use variable inside a function

TODO: maybe a more intelligent approach to replace - for ex,

// from
const [a] = b; return a;
const {a} = b; return a;

// to
return b[0];
return b.a;

+ (Close #151)
kangax pushed a commit that referenced this issue Sep 29, 2016
+ Bail out for replacement of single use variable inside a function

TODO: maybe a more intelligent approach to replace - for ex,

// from
const [a] = b; return a;
const {a} = b; return a;

// to
return b[0];
return b.a;

+ (Close #151)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants