-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Correct handling of newline after async with paren-less arrow func #8830
Conversation
…unction If async is followed by a newline, then a paren-less arrow function should be parsed as two expressions
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9221/ |
1 similar comment
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9221/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async
(x) => {}
Already works?
is a parse error, which seems consistent how other parsers treat it. (e.g. |
I think that it should be allowed (they are two expression statements), but you can test it in the console of a modern browser. |
Yeah, the version with parens is a syntax error in Firefox, Chrome, and Safari. (And the paren-less version is not) |
Oh ok 👍 |
Yeah the spec is a little difficult to read. Basically you're supposed to parse For the paren-less case there is no cover grammar to apply as there is no ambiguity. If there's a newline there's an ASI and if there's no newline then Thanks for fixing :) |
Assuming the issue reported in #8795 is correct (I haven't read the spec, but the described behavior seems to match other parsers such as flow or typescript), then
should parse as two expression statements, not a single arrow function like it currently does.