Fix parsing of nested classes with private fields
The parsing of private fields checks whether or not it is within a class to determine if it is valid or not. However, the state.inClass property is incorrect as it marks it as outside a class when the inner class is closed. This commit fixes this problem by replacing the state.inClass property with a class nesting counter.
This commit is contained in:
@@ -684,7 +684,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
// class bodies are implicitly strict
|
||||
const oldStrict = this.state.strict;
|
||||
this.state.strict = true;
|
||||
this.state.inClass = true;
|
||||
this.state.classLevel++;
|
||||
|
||||
const state = { hadConstructor: false };
|
||||
let decorators = [];
|
||||
@@ -731,7 +731,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
|
||||
node.body = this.finishNode(classBody, "ClassBody");
|
||||
|
||||
this.state.inClass = false;
|
||||
this.state.classLevel--;
|
||||
this.state.strict = oldStrict;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user