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

[JavaScript] Division operator should not be allowed after arrow functions #2750

Closed
Thom1729 opened this issue Mar 11, 2021 · 1 comment
Closed

Comments

@Thom1729
Copy link
Collaborator

From #1600.

Simple example:

x=>{}
/a/g;

The second line will be interpreted as a division expression, but it should actually be a regexp literal. The reason for this is that arrow function literals are in a weird place in the grammar — in AssignmentExpression, “below” the comma operator but “above” most other binary operators.

The existing behavior is correct for the two following examples:

x=>x
/a/g;
(x=>{})
/a/g;

This bug is obscure and unlikely to come up in practice, and several other parsers get it wrong too. And I suspect that fixing it might add more complexity than it's worth. But it is a bug, so here's a bug report.

@Thom1729
Copy link
Collaborator Author

And as soon I write this up, I find that I wrote it up two and a half years ago in #2144. Closing as duplicate.

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

1 participant