diff --git a/src/parser/expression.js b/src/parser/expression.js index 55fa1619f4..0cc3852b0b 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -765,7 +765,7 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) { if (isGenerator) this.unexpected(); let asyncId = this.parseIdentifier(); - if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR) || this.match(tt.eq)) { + if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR) || this.match(tt.eq) || this.match(tt.comma)) { prop.key = asyncId; } else { isAsync = true; diff --git a/test/fixtures/es2015/regression/186/actual.js b/test/fixtures/es2015/regression/186/actual.js new file mode 100644 index 0000000000..21a2ca9b13 --- /dev/null +++ b/test/fixtures/es2015/regression/186/actual.js @@ -0,0 +1 @@ +const x = {async}; diff --git a/test/fixtures/es2015/regression/186/expected.json b/test/fixtures/es2015/regression/186/expected.json new file mode 100644 index 0000000000..586102cb02 --- /dev/null +++ b/test/fixtures/es2015/regression/186/expected.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "method": false, + "shorthand": true, + "key": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "async" + }, + "name": "async" + }, + "extra": { + "shorthand": true + } + } + ] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file