diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-10-22 13:14:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-22 13:14:15 +0800 |
commit | 516eaef50c66aede72d3478a5653ae8651806258 (patch) | |
tree | d31d47d2c40a8c7e36ec1610e21a8f3ce0856260 | |
parent | 4ae1fb3ed8380d06220fd242037bd277fc21c17d (diff) | |
download | tracifyjs-516eaef50c66aede72d3478a5653ae8651806258.tar.gz tracifyjs-516eaef50c66aede72d3478a5653ae8651806258.zip |
fix `unsafe` evaluation of `AST_Sub` (#2389)
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/properties.js | 21 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index cef5d75f..6a40ef2a 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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); diff --git a/test/compress/properties.js b/test/compress/properties.js index c8a85697..45f870df 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -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"; + } +} |