Skip to content

Commit

Permalink
fix: do not eat get/set after async is parsed (#11916)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 5, 2020
1 parent de75d4f commit 9243426
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -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;
Expand Down
@@ -0,0 +1,4 @@
({
async get() {},
async set() {}
})
@@ -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": []
}
}

0 comments on commit 9243426

Please sign in to comment.