Navigation Menu

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

Recover from shorthand assign exprs #13968

Merged
merged 3 commits into from Nov 19, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Nov 15, 2021

Q                       A
Fixed Issues? Recover when parsing ({ x = 1 }) (could be an unfinished arrow head)
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Currently Babel throws unexpected token when parsing ({ x = 1 }).
We could recover in this case. It will be parsed as an assignment pattern under object property. This approach aligns to how we handle other errors such as doubleProto and privateKey.
The error message/code is copied from V8.

Also included some tweaks.

@JLHwung JLHwung added PR: Polish 💅 A type of pull request used for our changelog categories pkg: parser labels Nov 15, 2021
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8f55f57:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

this.classScope.usePrivateName(this.state.value, this.state.start);
node.property = this.parsePrivateName();
} else {
node.property = this.parseIdentifier(true);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for refactoring all of this to be more readable 😄

@JLHwung JLHwung merged commit a470f7b into babel:main Nov 19, 2021
@JLHwung JLHwung deleted the recover-from-shorthand-assign-exprs branch November 19, 2021 15:22
@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 Feb 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2022
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: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants