fix unsafe evaluation of objects (#2388)

This commit is contained in:
Alex Lam S.L
2017-10-22 04:19:40 +08:00
committed by GitHub
parent 011123223b
commit 4ae1fb3ed8
2 changed files with 19 additions and 0 deletions

View File

@@ -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;) {

View File

@@ -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"
}