Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove inClassProperty parser state #10906

Merged
merged 1 commit into from Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -1389,7 +1389,7 @@ export default class ExpressionParser extends LValParser {
if (this.eat(tt.dot)) {
const metaProp = this.parseMetaProperty(node, meta, "target");

if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) {
if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
let error = "new.target can only be used in functions";

if (this.hasPlugin("classProperties")) {
Expand Down
9 changes: 0 additions & 9 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -1048,11 +1048,9 @@ export default class StatementParser extends ExpressionParser {
}

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 = -1;
this.state.awaitPos = -1;
this.scope.enter(functionFlags(node.async, node.generator));
Expand Down Expand Up @@ -1084,7 +1082,6 @@ export default class StatementParser extends ExpressionParser {
}

this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.inClassProperty = oldInClassProperty;
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;

Expand Down Expand Up @@ -1575,13 +1572,10 @@ export default class StatementParser extends ExpressionParser {
parseClassPrivateProperty(
node: N.ClassPrivateProperty,
): N.ClassPrivateProperty {
this.state.inClassProperty = true;

this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);

node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null;
this.semicolon();
this.state.inClassProperty = false;

this.scope.exit();

Expand All @@ -1593,8 +1587,6 @@ export default class StatementParser extends ExpressionParser {
this.expectPlugin("classProperties");
}

this.state.inClassProperty = true;

this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);

if (this.match(tt.eq)) {
Expand All @@ -1605,7 +1597,6 @@ export default class StatementParser extends ExpressionParser {
node.value = null;
}
this.semicolon();
this.state.inClassProperty = false;

this.scope.exit();

Expand Down
1 change: 0 additions & 1 deletion packages/babel-parser/src/tokenizer/state.js
Expand Up @@ -64,7 +64,6 @@ export default class State {
inType: boolean = false;
noAnonFunctionType: boolean = false;
inPropertyName: boolean = false;
inClassProperty: boolean = false;
hasFlowComment: boolean = false;
isIterator: boolean = false;

Expand Down