diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-28 07:09:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 14:09:55 +0800 |
commit | 9e07ac410261dcbc074a29598a974b5de7cbe1da (patch) | |
tree | 95d7a59eb681ce9b514b8e92c8b88e2e69608d4a /test/compress | |
parent | 92d1391e5e3f6d2381233fc41f31ce0b808900ae (diff) | |
download | tracifyjs-9e07ac410261dcbc074a29598a974b5de7cbe1da.tar.gz tracifyjs-9e07ac410261dcbc074a29598a974b5de7cbe1da.zip |
fix corner case in `merge_vars` (#4158)
fixes #4157
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/merge_vars.js | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js index 7eb3f13c..5f4b6606 100644 --- a/test/compress/merge_vars.js +++ b/test/compress/merge_vars.js @@ -2617,9 +2617,9 @@ issue_4126_1: { try { console.log("PASS"); } catch (e) { - var c = a; + var b = a; } finally { - var c = c; + var c = b; } console.log(c); } @@ -2860,3 +2860,71 @@ issue_4155: { "function", ] } + +issue_4157_1: { + options = { + dead_code: true, + loops: true, + merge_vars: true, + } + input: { + (function() { + try { + for (var a = "FAIL"; a; a++) + return; + var b = 0; + } finally { + console.log(b); + } + })(); + } + expect: { + (function() { + try { + var a = "FAIL"; + if (a) + return; + var b = 0; + } finally { + console.log(b); + } + })(); + } + expect_stdout: "undefined" +} + +issue_4157_2: { + options = { + dead_code: true, + loops: true, + merge_vars: true, + } + input: { + (function() { + try { + throw "FAIL"; + } catch (e) { + for (var a = e; a; a++) + return; + var b = 0; + } finally { + console.log(b); + } + })(); + } + expect: { + (function() { + try { + throw "FAIL"; + } catch (e) { + var a = e; + if (a) + return; + var b = 0; + } finally { + console.log(b); + } + })(); + } + expect_stdout: "undefined" +} |