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

Issue with arrow and a specific syntax #259

Closed
gmarty opened this issue Sep 14, 2017 · 3 comments
Closed

Issue with arrow and a specific syntax #259

gmarty opened this issue Sep 14, 2017 · 3 comments

Comments

@gmarty
Copy link

gmarty commented Sep 14, 2017

I think the following syntax causes a bug with the arrow transform:

var a = function(b) {
  return {
    a: 1,
    b: 2,
  }[b];
};

More specifically the [b] after the return seems to be the cause of it.

nene added a commit that referenced this issue Sep 14, 2017
The second tests fails, so marking it as skipped.
Expecting that it's a bug in Recast.

Refs #259
@nene
Copy link
Collaborator

nene commented Sep 14, 2017

Thanks for reporting.

I see that the transform works without crashing, but results in invalid JavaScript:

var a = b => {
  a: 1,
  b: 2,
}[a];

it really should be:

var a = b => ({
  a: 1,
  b: 2,
}[a]);

Seems to be a bug in Recast library that handles turning the transformed AST back to code. It has a history of bugs related to the placement of parentheses.

@nene
Copy link
Collaborator

nene commented Sep 14, 2017

Recast has on open bug for a very similar-looking issue: benjamn/recast#351

@nene nene mentioned this issue Sep 15, 2017
nene added a commit that referenced this issue Sep 12, 2018
Recent upgrade of Recast has fixed it.

Refs #259
@nene
Copy link
Collaborator

nene commented Sep 13, 2018

Fixed in 3.0.2

@nene nene closed this as completed Sep 13, 2018
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

2 participants