Throw on duplicate __proto__ props followed by assignment (#13951)

This commit is contained in:
Sneh Khatri
2021-11-12 19:15:56 +05:30
committed by GitHub
parent dd63950c99
commit 135ab837bc
7 changed files with 176 additions and 79 deletions

View File

@@ -309,17 +309,18 @@ export default class ExpressionParser extends LValParser {
if (this.match(tt.eq)) {
node.left = this.toAssignable(left, /* isLHS */ true);
refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression
if (refExpressionErrors.doubleProto >= startPos) {
refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression
}
if (refExpressionErrors.shorthandAssign >= startPos) {
refExpressionErrors.shorthandAssign = -1; // reset because shorthand default was used correctly
}
} else {
node.left = left;
}
if (refExpressionErrors.shorthandAssign >= node.left.start) {
refExpressionErrors.shorthandAssign = -1; // reset because shorthand default was used correctly
}
this.checkLVal(left, "assignment expression");
this.next();
node.right = this.parseMaybeAssign();
return this.finishNode(node, "AssignmentExpression");