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

fixed missing errors on assignment pattern in object expression #10607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -204,7 +204,10 @@ export default class ExpressionParser extends LValParser {
node.left = this.match(tt.eq)
? this.toAssignable(left, undefined, "assignment expression")
: left;
refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly

if (refShorthandDefaultPos.start >= node.left.start) {
refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly
}

this.checkLVal(left, undefined, undefined, "assignment expression");

Expand Down
@@ -0,0 +1,4 @@
const obj = {
bar: x = 123,
foo = 123
};
@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (3:6)"
}
@@ -0,0 +1,4 @@
const obj = {
foo = 123,
bar: x = 123
};
@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:6)"
}
@@ -0,0 +1,4 @@
const obj = {
foo = 123,
bar: x = 123,
} = { foo: 24, bar: 45 };