diff --git a/src/parser/expression.js b/src/parser/expression.js index 1b9e835afe..5faf80afce 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -593,7 +593,7 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) { if (!isPattern && this.options.features["es7.asyncFunctions"] && this.isContextual("async")) { if (isGenerator) this.unexpected(); var asyncId = this.parseIdent(); - if (this.match(tt.colon) || this.match(tt.parenL)) { + if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR)) { prop.key = asyncId; } else { isAsync = true; diff --git a/test/fixtures/experimental/async-functions/object-last-property-shorthand/actual.js b/test/fixtures/experimental/async-functions/object-last-property-shorthand/actual.js new file mode 100644 index 0000000000..cbc62b2ff9 --- /dev/null +++ b/test/fixtures/experimental/async-functions/object-last-property-shorthand/actual.js @@ -0,0 +1 @@ +foo({ async }); diff --git a/test/fixtures/experimental/async-functions/object-last-property-shorthand/expected.json b/test/fixtures/experimental/async-functions/object-last-property-shorthand/expected.json new file mode 100644 index 0000000000..b43eede7d6 --- /dev/null +++ b/test/fixtures/experimental/async-functions/object-last-property-shorthand/expected.json @@ -0,0 +1,148 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "name": "foo" + }, + "arguments": [ + { + "type": "ObjectExpression", + "start": 4, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [ + { + "type": "Property", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "method": false, + "shorthand": true, + "key": { + "type": "Identifier", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": "async" + }, + "kind": "init", + "value": { + "type": "Identifier", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": "async" + } + } + ] + } + ] + } + } + ] + } +} \ No newline at end of file