Set generator to true during error recovery of accessor (#11987)

This commit is contained in:
Brian Ng 2020-08-21 14:37:52 -05:00 committed by GitHub
parent b9407d7660
commit 941f610275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1767,6 +1767,7 @@ export default class ExpressionParser extends LValParser {
isAccessor = true;
prop.kind = keyName;
if (this.match(tt.star)) {
isGenerator = true;
this.raise(this.state.pos, Errors.AccessorIsGenerator, keyName);
this.next();
}
@ -1827,7 +1828,9 @@ export default class ExpressionParser extends LValParser {
// isAccessor implies isAsync: false, isPattern: false, isGenerator: false
this.parseMethod(
prop,
/* isGenerator */ false,
// This _should_ be false, but with error recovery, we allow it to be
// set for informational purposes
isGenerator,
/* isAsync */ false,
/* isConstructor */ false,
false,

View File

@ -30,7 +30,7 @@
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"generator": true,
"async": false,
"params": [],
"body": {
@ -52,7 +52,7 @@
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"generator": true,
"async": false,
"params": [
{