Disallow escape sequences in contextual keywords (#9618)

* Disallow escape sequences in async

* Disallow escape sequences in get, set and async in class

* invalid escape tests

* Update whitelist

* tests for async in parens

* Add test for invalid newline between params and arrow

* Move canInsertSemilcolon() into shouldPArseAsyncArrow
This commit is contained in:
Daniel Tschinder
2019-03-05 17:20:36 -08:00
committed by GitHub
parent 349c0d4836
commit 29999007f6
58 changed files with 530 additions and 22 deletions

View File

@@ -2619,6 +2619,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
startLoc: Position,
noCalls: ?boolean,
subscriptState: N.ParseSubscriptState,
maybeAsyncArrow: boolean,
): N.Expression {
if (this.match(tt.questionDot) && this.isLookaheadRelational("<")) {
this.expectPlugin("optionalChaining");
@@ -2671,6 +2672,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
startLoc,
noCalls,
subscriptState,
maybeAsyncArrow,
);
}

View File

@@ -1498,6 +1498,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
startLoc: Position,
noCalls: ?boolean,
state: N.ParseSubscriptState,
maybeAsyncArrow: boolean,
): N.Expression {
if (!this.hasPrecedingLineBreak() && this.match(tt.bang)) {
this.state.exprAllowed = false;
@@ -1560,7 +1561,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (result) return result;
}
return super.parseSubscript(base, startPos, startLoc, noCalls, state);
return super.parseSubscript(
base,
startPos,
startLoc,
noCalls,
state,
maybeAsyncArrow,
);
}
parseNewArguments(node: N.NewExpression): void {