-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
ObjectPattern should be checked in toAssignableList
packages/babylon/src/parser/lval.js
Outdated
@@ -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" |
There was a problem hiding this comment.
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
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6123/ |
That syntax is not allowed in the test262 test suites (https://github.com/babel/babel/pull/6986/files#diff-146d031d23e0df2adf55d70f79b7e12c) ? |
@xtuc That tests where whitelisted because they should have passed but they didn't. In fact the travis ci error is
|
@ksashikumar thanks! |
ObjectPattern should be checked in toAssignableList
Spec: https://tc39.github.io/ecma262/#sec-destructuring-assignment
An
AssignmentRestElement
is defined as... DestructuringAssignmentTarget
.DestructuringAssignmentTarget
isLeftHandSideExpression
, which in assignment contexts can be anyAssignmentPattern
(https://tc39.github.io/ecma262/#sec-destructuring-assignment), so... ObjectAssignmentPattern
is a validAssignmentRestElement