fix unsafe evaluation of objects (#2388)
This commit is contained in:
@@ -4492,6 +4492,7 @@ merge(Compressor.prototype, {
|
||||
if (def) {
|
||||
return def.optimize(compressor);
|
||||
}
|
||||
if (is_lhs(self, compressor.parent())) return self;
|
||||
if (compressor.option("unsafe") && self.expression instanceof AST_Object) {
|
||||
var values = self.expression.properties;
|
||||
for (var i = values.length; --i >= 0;) {
|
||||
|
||||
@@ -804,3 +804,21 @@ issue_2256: {
|
||||
g.keep = g.g;
|
||||
}
|
||||
}
|
||||
|
||||
lhs_prop: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
unsafe: true,
|
||||
}
|
||||
input: {
|
||||
console.log(++{
|
||||
a: 1
|
||||
}.a);
|
||||
}
|
||||
expect: {
|
||||
console.log(++{
|
||||
a: 1
|
||||
}.a);
|
||||
}
|
||||
expect_stdout: "2"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user