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

Fix parsing of awaited tagged template expressions #376

Closed
wants to merge 2 commits into from

Conversation

rtsao
Copy link
Contributor

@rtsao rtsao commented Sep 8, 2020

Fixes #372

Before this, the parser would incorrectly parse await foo`bar` as Template(Await(...)) instead of Await(Template(...))

I assume LPrefix was used before because of the location of await in the precedence table (17), but it seems this doesn't match up with the observed behavior of other parsers.

In addition to tagged templates (with and without substitutions), I added test cases for await with both the lowest (comma) and highest (grouping and property access) operators.

@evanw
Copy link
Owner

evanw commented Sep 8, 2020

Unfortunately I don't believe this is a valid fix for this issue. This change means await 1, 2 would be incorrectly parsed as await (1, 2) while it should be parsed as (await 1), 2 instead. This happens because changing LPrefix to LLowest here means "continue parsing all operators of any precedence after the await token".

Edit: One way to tell is to do await 1 == 1. That should be parsed as (await 1) == 1 but instead it's parsed as await (1 == 1) which esbuild prints as await true.

@rtsao rtsao closed this Sep 8, 2020
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

Successfully merging this pull request may close these issues.

Breaks async template literal tags
2 participants