diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-24 03:19:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-24 10:19:43 +0800 |
commit | 8e86d05c3228635ad969e38ce5f90b2a75d1885c (patch) | |
tree | d5fc48c89f6d1f0047c304941628d5673b2ea65d /test | |
parent | 9e40abededaae3568e6cd931268cfaa0bd0ffbc0 (diff) | |
download | tracifyjs-8e86d05c3228635ad969e38ce5f90b2a75d1885c.tar.gz tracifyjs-8e86d05c3228635ad969e38ce5f90b2a75d1885c.zip |
fix corner case in `merge_vars` (#4238)
fixes #4237
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/merge_vars.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js index 28a0135d..6ada9297 100644 --- a/test/compress/merge_vars.js +++ b/test/compress/merge_vars.js @@ -3011,3 +3011,84 @@ issue_4168_use_strict: { } expect_stdout: "PASS true 42" } + +issue_4237_1: { + options = { + merge_vars: true, + } + input: { + console.log(function(a) { + do { + var b = a++; + if (b) + return "FAIL"; + continue; + var c = 42; + } while ("undefined" != typeof c); + return "PASS"; + }(0)); + } + expect: { + console.log(function(a) { + do { + var b = a++; + if (b) + return "FAIL"; + continue; + var c = 42; + } while ("undefined" != typeof c); + return "PASS"; + }(0)); + } + expect_stdout: "PASS" +} + +issue_4237_2: { + options = { + dead_code: true, + evaluate: true, + loops: true, + merge_vars: true, + switches: true, + } + input: { + console.log(function(a) { + do { + switch (0) { + case 0: + var b = a++; + default: + while (b) + return "FAIL"; + } + try { + var c = 0; + } finally { + continue; + } + var d = 0; + } while ("undefined" != typeof d); + return "PASS"; + }(0)); + } + expect: { + console.log(function(a) { + do { + switch (0) { + case 0: + var b = a++; + if (b) + return "FAIL"; + } + try { + var c = 0; + } finally { + continue; + } + var d = 0; + } while ("undefined" != typeof d); + return "PASS"; + }(0)); + } + expect_stdout: "PASS" +} |