properly distinguish shorthand async keys that are the last property - fixes #2176
This commit is contained in:
parent
5ec9f78493
commit
4fda34ce6f
@ -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;
|
||||
|
||||
1
test/fixtures/experimental/async-functions/object-last-property-shorthand/actual.js
vendored
Normal file
1
test/fixtures/experimental/async-functions/object-last-property-shorthand/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
foo({ async });
|
||||
148
test/fixtures/experimental/async-functions/object-last-property-shorthand/expected.json
vendored
Normal file
148
test/fixtures/experimental/async-functions/object-last-property-shorthand/expected.json
vendored
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user