fix corner case in join_vars (#3917)

fixes #3916
This commit is contained in:
Alex Lam S.L
2020-05-21 22:26:46 +01:00
committed by GitHub
parent aeb9ea5ac2
commit fa14a9cfcd
2 changed files with 33 additions and 1 deletions

View File

@@ -2508,7 +2508,7 @@ merge(Compressor.prototype, {
}
if (prop instanceof AST_Node) break;
prop = "" + prop;
var diff = compressor.has_directive("use strict") ? function(node) {
var diff = prop == "__proto__" || compressor.has_directive("use strict") ? function(node) {
return node.key != prop && node.key.name != prop;
} : function(node) {
return node.key.name != prop;

View File

@@ -1023,3 +1023,35 @@ issue_3856: {
}
expect_stdout: "undefined"
}
issue_3916: {
options = {
join_vars: true,
}
input: {
var o = {};
o.p = "PASS";
o.__proto__ = 42;
o.q = "FAIL";
o.__proto__ = {
p: "FAIL",
q: "PASS",
};
o.__proto__ = "foo";
console.log(typeof o.__proto__, o.p, delete o.q, o.q);
}
expect: {
var o = {
p: "PASS",
__proto__: 42,
q: "FAIL",
};
o.__proto__ = {
p: "FAIL",
q: "PASS",
};
o.__proto__ = "foo";
console.log(typeof o.__proto__, o.p, delete o.q, o.q);
}
expect_stdout: "object PASS true PASS"
}