Skip to content

Commit

Permalink
fixed missing errors on assignment pattern in object expression (#10607)
Browse files Browse the repository at this point in the history
* 馃悰 fixed missing errors on assignment pattern in object expression

* 鈾伙笍 remove a non-needed comment

* 馃悰 missed adding comma in the test input

* 馃悰 fixed the failing valid-property-initializer test
  • Loading branch information
vivek12345 authored and nicolo-ribaudo committed Oct 29, 2019
1 parent 198b4a0 commit 4b3a19e
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 1 deletion.
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 };

0 comments on commit 4b3a19e

Please sign in to comment.