diff --git a/src/parser/expression.js b/src/parser/expression.js index af0ce802a3..050bc72f42 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -822,7 +822,13 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync, return this.finishNode(prop, "ObjectProperty"); } - if (!isPattern && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (!this.match(tt.comma) && !this.match(tt.braceR))) { + if ( + !isPattern && + !prop.computed && + prop.key.type === "Identifier" && + (prop.key.name === "get" || prop.key.name === "set") && + (!this.match(tt.comma) && !this.match(tt.braceR) && !this.match(tt.eq)) + ) { if (isGenerator || isAsync) this.unexpected(); prop.kind = prop.key.name; this.parsePropertyName(prop); diff --git a/test/fixtures/es2015/uncategorised/393/actual.js b/test/fixtures/es2015/uncategorised/393/actual.js new file mode 100644 index 0000000000..684a2cd150 --- /dev/null +++ b/test/fixtures/es2015/uncategorised/393/actual.js @@ -0,0 +1 @@ +({set = {}}) => set; diff --git a/test/fixtures/es2015/uncategorised/393/expected.json b/test/fixtures/es2015/uncategorised/393/expected.json new file mode 100644 index 0000000000..8a7f651b62 --- /dev/null +++ b/test/fixtures/es2015/uncategorised/393/expected.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "set" + }, + "name": "set" + }, + "value": { + "type": "AssignmentPattern", + "start": 2, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "set" + }, + "name": "set" + }, + "right": { + "type": "ObjectExpression", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "properties": [] + } + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "set" + }, + "name": "set" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file