Skip to content

[parser] Recover after using await expressions in sync contexts#11090

Closed
nicolo-ribaudo wants to merge 1 commit into
babel:masterfrom
nicolo-ribaudo:sync-await-error-recovery
Closed

[parser] Recover after using await expressions in sync contexts#11090
nicolo-ribaudo wants to merge 1 commit into
babel:masterfrom
nicolo-ribaudo:sync-await-error-recovery

Conversation

@nicolo-ribaudo

Copy link
Copy Markdown
Member
Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes, but I don't think that it needs to wait for a minor version.
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories pkg: parser area: errors labels Feb 3, 2020
@nicolo-ribaudo nicolo-ribaudo changed the title [parser] Recover aftwe using await expressions in sync contexts [parser] Recover after using await expressions in sync contexts Feb 3, 2020
@nicolo-ribaudo nicolo-ribaudo force-pushed the sync-await-error-recovery branch from 6c26e5d to 8dcf566 Compare February 3, 2020 21:19
},
"errors": [
"SyntaxError: Await expressions are only allowed inside async functions. (1:11)",
"SyntaxError: Await cannot be used as name inside an async function (1:11)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case there are two contradicting errors in the same position, IMO it is confusing and we should fix it.

: "Await expressions are only allowed inside async functions.",
);

return this.parseAwait(startPos, startLoc);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reset the awaitPos after await expression is parsed since we have thrown an recoverable error before.

@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 25, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: errors outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants