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 destructuring assignment spec violation #6986

Merged
merged 3 commits into from
Dec 7, 2017

Conversation

ksashikumar
Copy link
Contributor

ObjectPattern should be checked in toAssignableList

Q                       A
Fixed Issues? #6682
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR
Any Dependency Changes?
License MIT

Spec: https://tc39.github.io/ecma262/#sec-destructuring-assignment

An AssignmentRestElement is defined as ... DestructuringAssignmentTarget. DestructuringAssignmentTarget is LeftHandSideExpression, which in assignment contexts can be any AssignmentPattern (https://tc39.github.io/ecma262/#sec-destructuring-assignment), so ... ObjectAssignmentPattern is a valid AssignmentRestElement

ObjectPattern should be checked in toAssignableList
@@ -150,7 +150,8 @@ export default class LValParser extends NodeUtils {
if (
arg.type !== "Identifier" &&
arg.type !== "MemberExpression" &&
arg.type !== "ArrayPattern"
arg.type !== "ArrayPattern" &&
arg.type !== "ObjectPattern"
Copy link
Member

Choose a reason for hiding this comment

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

We could probably transform that into a Array lookup for readability, but lgtm. Thanks for your contrib @ksashikumar

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 7, 2017

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6123/

@xtuc
Copy link
Member

xtuc commented Dec 7, 2017

That syntax is not allowed in the test262 test suites (https://github.com/babel/babel/pull/6986/files#diff-146d031d23e0df2adf55d70f79b7e12c) ?

@nicolo-ribaudo
Copy link
Member

@xtuc That tests where whitelisted because they should have passed but they didn't. In fact the travis ci error is

✘ 57 valid programs parsed without error (in violation of the whitelist file)

@existentialism existentialism added PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Spec Compliance 👓 A type of pull request used for our changelog categories labels Dec 7, 2017
@existentialism existentialism merged commit ac745de into babel:master Dec 7, 2017
@existentialism
Copy link
Member

@ksashikumar thanks!

@ksashikumar ksashikumar deleted the bug-6682 branch December 27, 2017 16:22
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Spec Compliance 👓 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants