* Allow duplicate __proto__ keys in patterns, simple case (#6705) * Update test262 whitelist * Rename checkDuplicatedProto's parameter and adjust type * Store first __proto__ redefinition's position
This commit is contained in:
committed by
Nicolò Ribaudo
parent
dcf7d89b8e
commit
06313a6288
@@ -125,9 +125,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
checkPropClash(
|
||||
checkDuplicatedProto(
|
||||
prop: N.ObjectMember | N.SpreadElement,
|
||||
propHash: { [key: string]: boolean },
|
||||
protoRef: { used: boolean, start?: number },
|
||||
): void {
|
||||
if (
|
||||
prop.type === "SpreadElement" ||
|
||||
@@ -144,10 +144,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const name = key.type === "Identifier" ? key.name : String(key.value);
|
||||
|
||||
if (name === "__proto__" && prop.kind === "init") {
|
||||
if (propHash.proto) {
|
||||
this.raise(key.start, "Redefinition of __proto__ property");
|
||||
// Store the first redefinition's position
|
||||
if (protoRef.used && !protoRef.start) {
|
||||
protoRef.start = key.start;
|
||||
}
|
||||
propHash.proto = true;
|
||||
|
||||
protoRef.used = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user