Skip to content

Incorrect parenthesization of arrow functions #31

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
Conduitry opened this issue Feb 7, 2020 · 3 comments
Closed

Incorrect parenthesization of arrow functions #31

Conduitry opened this issue Feb 7, 2020 · 3 comments

Comments

@Conduitry
Copy link
Collaborator

Conduitry commented Feb 7, 2020

cr.print(cr.x`foo || (bar => bar)`).code

results in

foo || bar => bar

which is syntactically incorrect. The arrow function needs to be wrapped in parentheses. I'm not sure what precedence rules are in play here or what needs changing.

Ref sveltejs/svelte#4384

@Conduitry
Copy link
Collaborator Author

Aside:

cr.print(cr.x`foo || bar => bar`).code

results in

foo || bar

for some reason. I guess Acorn silently stops parsing when it sees the invalid =>? I'm not sure whether that should be considered a bug.

@Rich-Harris
Copy link
Owner

Yeah, Acorn just ignores anything past the first valid expression. Definitely a bug for our situation

Rich-Harris added a commit that referenced this issue Feb 7, 2020
failing tests and partial fix for #31
@Rich-Harris
Copy link
Owner

fixed in 0.1.1

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

No branches or pull requests

2 participants