fix: do not eat get/set after async is parsed (#11916)
This commit is contained in:
parent
de75d4f081
commit
92434269af
@ -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;
|
||||
|
||||
4
packages/babel-parser/test/fixtures/es2017/async-functions/async-shorthand-method/input.js
vendored
Normal file
4
packages/babel-parser/test/fixtures/es2017/async-functions/async-shorthand-method/input.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
({
|
||||
async get() {},
|
||||
async set() {}
|
||||
})
|
||||
71
packages/babel-parser/test/fixtures/es2017/async-functions/async-shorthand-method/output.json
vendored
Normal file
71
packages/babel-parser/test/fixtures/es2017/async-functions/async-shorthand-method/output.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user