diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-01 16:18:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 16:18:29 +0800 |
commit | aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9 (patch) | |
tree | fad3c0fb8567c8f0f9fed15e4bb276ace522f602 /test | |
parent | 102f994b9d09b3ed0447f02a894fd88fcc903171 (diff) | |
download | tracifyjs-aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9.tar.gz tracifyjs-aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9.zip |
avoid `evaluate` of compound assignment after `dead_code` transform (#2861)
fixes #2860
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/dead-code.js | 38 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 40 |
2 files changed, 78 insertions, 0 deletions
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index b66d5ac1..9b45fe87 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -879,3 +879,41 @@ unsafe_builtin: { z; } } + +issue_2860_1: { + options = { + dead_code: true, + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + }()); + } + expect: { + console.log(function(a) { + return 1 ^ a; + }()); + } + expect_stdout: "1" +} + +issue_2860_2: { + options = { + dead_code: true, + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + }()); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 2e562f94..761af9e2 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -5467,3 +5467,43 @@ chained_assignments: { } expect_stdout: "5eadbeef" } + +issue_2860_1: { + options = { + dead_code: true, + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + a ^= 2; + }()); + } + expect: { + console.log(function(a) { + return 1 ^ a; + }()); + } + expect_stdout: "1" +} + +issue_2860_2: { + options = { + dead_code: true, + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + a ^= 2; + }()); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} |