diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-18 12:38:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-18 19:38:09 +0800 |
commit | a7e7865e6bb446d7bcb26fa96d57041c65001d01 (patch) | |
tree | a6e636d327267ce845fe63b39cf7aa015cf3e006 /test | |
parent | ef5f7fc25e93833396540cf7479685b241bd1b8f (diff) | |
download | tracifyjs-a7e7865e6bb446d7bcb26fa96d57041c65001d01.tar.gz tracifyjs-a7e7865e6bb446d7bcb26fa96d57041c65001d01.zip |
fix corner case in `unused` (#5086)
fixes #5085
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/destructured.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 06fb57cd..4ba32f3e 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -2948,3 +2948,53 @@ issue_5074_method_pure_getters: { expect_stdout: "PASS" node_version: ">=6" } + +issue_5085_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + var a = "PASS"; + var [ b ] = [ 42, a ], c = b ? 0 : a = "FAIL"; + console.log(a); + } + expect: { + var a = "PASS"; + var b = [ 42 ][0]; + b; + console.log(a); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5085_2: { + options = { + evaluate: true, + reduce_vars: true, + side_effects: true, + unsafe: true, + unused: true, + } + input: { + var a = "PASS"; + (function(b) { + [ b ] = [ 42, a ]; + var c = b ? 0 : a = "FAIL"; + })(); + console.log(a); + } + expect: { + var a = "PASS"; + (function(b) { + b = [ 42 ][0]; + })(); + console.log(a); + } + expect_stdout: "PASS" + node_version: ">=6" +} |