properly distinguish shorthand async keys that are the last property - fixes #2176

This commit is contained in:
Sebastian McKenzie 2015-08-06 19:33:48 +01:00
parent 5ec9f78493
commit 4fda34ce6f
3 changed files with 150 additions and 1 deletions

View File

@ -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;

View File

@ -0,0 +1 @@
foo({ async });

View 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"
}
}
]
}
]
}
}
]
}
}