suppress unsafe_proto for LHS expressions (#2804)

This commit is contained in:
Alex Lam S.L
2018-01-17 20:41:51 +08:00
committed by GitHub
parent cff3bf4914
commit d3ce2bc9e7
2 changed files with 20 additions and 1 deletions

View File

@@ -5644,6 +5644,7 @@ merge(Compressor.prototype, {
if (def) {
return def.optimize(compressor);
}
if (is_lhs(self, compressor.parent())) return self;
if (compressor.option("unsafe_proto")
&& self.expression instanceof AST_Dot
&& self.expression.property == "prototype") {
@@ -5682,7 +5683,6 @@ merge(Compressor.prototype, {
break;
}
}
if (is_lhs(self, compressor.parent())) return self;
var sub = self.flatten_object(self.property, compressor);
if (sub) return sub.optimize(compressor);
var ev = self.evaluate(compressor);

View File

@@ -583,6 +583,25 @@ native_prototype: {
}
}
native_prototype_lhs: {
options = {
unsafe_proto: true,
}
input: {
console.log(function() {
Function.prototype.bar = "PASS";
return function() {};
}().bar);
}
expect: {
console.log(function() {
Function.prototype.bar = "PASS";
return function() {};
}().bar);
}
expect_stdout: "PASS"
}
accessor_boolean: {
input: {
var a = 1;