Disallow await inside async arrow params (#10469)

* Disallow await inside async arrow params

* Use -1 as default for awaitPos/yieldPos
This commit is contained in:
Nicolò Ribaudo
2019-10-02 07:37:40 +02:00
committed by GitHub
parent fa5057f9fb
commit a219b6de7a
11 changed files with 526 additions and 41 deletions

View File

@@ -1050,12 +1050,14 @@ export default class StatementParser extends ExpressionParser {
node.id = this.parseFunctionId(requireId);
}
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
const oldInClassProperty = this.state.inClassProperty;
const oldYieldPos = this.state.yieldPos;
const oldAwaitPos = this.state.awaitPos;
this.state.maybeInArrowParameters = false;
this.state.inClassProperty = false;
this.state.yieldPos = 0;
this.state.awaitPos = 0;
this.state.yieldPos = -1;
this.state.awaitPos = -1;
this.scope.enter(functionFlags(node.async, node.generator));
if (!isStatement) {
@@ -1084,6 +1086,7 @@ export default class StatementParser extends ExpressionParser {
this.checkFunctionStatementId(node);
}
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.inClassProperty = oldInClassProperty;
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;