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

[parser] Regex on new line after `typeof async function` is division #10410

pvdz opened this issue Sep 7, 2019 · 1 comment


Copy link

commented Sep 7, 2019

Bug Report

Parser is incorrectly handling a parsing edge case. When a regular expression follows a typeof expression on a new line, without semi-colon, there is no ASI and so it should be a division.

Current Behavior

It'll try to parse a regular expression on the input code

Input Code

Babel 7.5.5

typeof async function f(){}

(It seems to behave correctly for a regular function or just x as the typeof argument)

For reference, the next should pass but will crash in Babel (and Acorn):

typeof async function f(){}
/ foo

And for the sake of completion, the next example should fail:

typeof async function f(){}

Expected behavior/code

It should parse a division (so ((typeof x) / foo) / g). See output of Esprima, for example. Acorn has the same problem.

Possible Solution
At its core, the "are we parsing a regex or division" flag is incorrectly passed to the lexer. In the actual parser its implementation may be more complex than that.

Additional context/Screenshots

It's a super edge case and pretty low prio.

@pvdz pvdz changed the title [parser] Regex on new line after `typeof async function` [parser] Regex on new line after `typeof async function` is division Sep 7, 2019


This comment has been minimized.

Copy link

commented Sep 7, 2019

Hey @pvdz! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.