Parse class heritage as strict mode code (#9315)

This commit is contained in:
Nicolò Ribaudo
2019-01-12 14:54:23 +01:00
committed by GitHub
parent 28319eb07e
commit 3e4b608a80
5 changed files with 16 additions and 6 deletions

View File

@@ -994,8 +994,16 @@ export default class StatementParser extends ExpressionParser {
this.next();
this.takeDecorators(node);
this.parseClassId(node, isStatement, optionalId);
// class bodies and heritages are implicitly strict
const oldStrict = this.state.strict;
this.state.strict = true;
this.parseClassSuper(node);
this.parseClassBody(node);
this.state.strict = oldStrict;
return this.finishNode(
node,
isStatement ? "ClassDeclaration" : "ClassExpression",
@@ -1020,9 +1028,6 @@ export default class StatementParser extends ExpressionParser {
}
parseClassBody(node: N.Class): void {
// class bodies are implicitly strict
const oldStrict = this.state.strict;
this.state.strict = true;
this.state.classLevel++;
const state = { hadConstructor: false };
@@ -1087,7 +1092,6 @@ export default class StatementParser extends ExpressionParser {
node.body = this.finishNode(classBody, "ClassBody");
this.state.classLevel--;
this.state.strict = oldStrict;
}
parseClassMember(