fix: triple __proto__ in object patterns should be allowed (#11009)

This commit is contained in:
Huáng Jùnliàng
2020-01-16 09:34:47 -05:00
committed by GitHub
parent 6363b594cc
commit a1063d2583
3 changed files with 267 additions and 3 deletions

View File

@@ -88,10 +88,13 @@ export default class ExpressionParser extends LValParser {
const name = key.type === "Identifier" ? key.name : String(key.value);
if (name === "__proto__") {
// Store the first redefinition's position
if (protoRef.used) {
if (refExpressionErrors && refExpressionErrors.doubleProto === -1) {
refExpressionErrors.doubleProto = key.start;
if (refExpressionErrors) {
// Store the first redefinition's position, otherwise ignore because
// we are parsing ambiguous pattern
if (refExpressionErrors.doubleProto === -1) {
refExpressionErrors.doubleProto = key.start;
}
} else {
this.raise(key.start, "Redefinition of __proto__ property");
}