fix unsafe evaluation of AST_Sub (#2389)

This commit is contained in:
Alex Lam S.L
2017-10-22 13:14:15 +08:00
committed by GitHub
parent 4ae1fb3ed8
commit 516eaef50c
2 changed files with 21 additions and 1 deletions

View File

@@ -4468,6 +4468,7 @@ merge(Compressor.prototype, {
});
}
}
if (is_lhs(self, compressor.parent())) return self;
var ev = self.evaluate(compressor);
if (ev !== self) {
ev = make_node_from_constant(ev, self).optimize(compressor);

View File

@@ -805,7 +805,7 @@ issue_2256: {
}
}
lhs_prop: {
lhs_prop_1: {
options = {
evaluate: true,
unsafe: true,
@@ -822,3 +822,22 @@ lhs_prop: {
}
expect_stdout: "2"
}
lhs_prop_2: {
options = {
evaluate: true,
inline: true,
reduce_vars: true,
side_effects: true,
unsafe: true,
unused: true,
}
input: {
(function(a) {
a[2] = "g";
})("abc");
}
expect: {
"abc"[2] = "g";
}
}