fix: do not eat get/set after async is parsed (#11916)

This commit is contained in:
Huáng Jùnliàng 2020-08-05 09:19:59 -04:00 committed by GitHub
parent de75d4f081
commit 92434269af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 1 deletions

View File

@ -1754,7 +1754,7 @@ export default class ExpressionParser extends LValParser {
}
// get PropertyName[?Yield, ?Await] () { FunctionBody[~Yield, ~Await] }
// set PropertyName[?Yield, ?Await] ( PropertySetParameterList ) { FunctionBody[~Yield, ~Await] }
if (prop.key.name === "get" || prop.key.name === "set") {
else if (prop.key.name === "get" || prop.key.name === "set") {
isAccessor = true;
isGenerator = this.eat(tt.star); // tt.star is allowed in `maybeAsyncOrAccessorProp`, we will throw in `parseObjectMethod` later
prop.kind = prop.key.name;

View File

@ -0,0 +1,4 @@
({
async get() {},
async set() {}
})

View File

@ -0,0 +1,71 @@
{
"type": "File",
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"program": {
"type": "Program",
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"expression": {
"type": "ObjectExpression",
"start":1,"end":39,"loc":{"start":{"line":1,"column":1},"end":{"line":4,"column":1}},
"properties": [
{
"type": "ObjectMethod",
"start":5,"end":19,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}},
"method": true,
"key": {
"type": "Identifier",
"start":11,"end":14,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":11},"identifierName":"get"},
"name": "get"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start":17,"end":19,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":16}},
"body": [],
"directives": []
}
},
{
"type": "ObjectMethod",
"start":23,"end":37,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":16}},
"method": true,
"key": {
"type": "Identifier",
"start":29,"end":32,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":11},"identifierName":"set"},
"name": "set"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start":35,"end":37,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":16}},
"body": [],
"directives": []
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}