diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-07 02:00:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 10:00:04 +0800 |
commit | 4bbeb09f7c12bfb3d12ac5264bbdf033ee0b66dc (patch) | |
tree | 78b2c332b58edf8b8b4dab82ff129657ce1d21af /test/compress | |
parent | c2f6fd5fded46624da3851e3accc3b5165e6d588 (diff) | |
download | tracifyjs-4bbeb09f7c12bfb3d12ac5264bbdf033ee0b66dc.tar.gz tracifyjs-4bbeb09f7c12bfb3d12ac5264bbdf033ee0b66dc.zip |
fix corner case in `reduce_vars` (#4262)
fixes #4261
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/const.js | 40 | ||||
-rw-r--r-- | test/compress/functions.js | 52 |
2 files changed, 87 insertions, 5 deletions
diff --git a/test/compress/const.js b/test/compress/const.js index 896e8c38..9ffb0d34 100644 --- a/test/compress/const.js +++ b/test/compress/const.js @@ -1135,3 +1135,43 @@ issue_4248: { } expect_stdout: "PASS" } + +issue_4261: { + options = { + inline: true, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + { + const a = 42; + (function() { + function f() { + console.log(a); + } + function g() { + while (f()); + } + (function() { + while (g()); + })(); + })(); + } + } + expect: { + { + const a = 42; + (function() { + function g() { + while (void console.log(a)); + } + (function() { + while (g()); + })(); + })(); + } + } + expect_stdout: "42" +} diff --git a/test/compress/functions.js b/test/compress/functions.js index c2ab23f6..3b57fb2b 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2081,7 +2081,7 @@ issue_3016_1: { var b = 1; do { 3[b]; - } while(0); + } while (0); console.log(b); } expect_stdout: "1" @@ -2112,7 +2112,7 @@ issue_3016_2: { do { a = 3, a[b]; - } while(0); + } while (0); var a; console.log(b); } @@ -2145,7 +2145,7 @@ issue_3016_2_ie8: { do { a = 3, a[b]; - } while(0); + } while (0); var a; console.log(b); } @@ -2175,7 +2175,7 @@ issue_3016_3: { var b = 1; do { console.log((a = void 0, a ? "FAIL" : a = "PASS")); - } while(b--); + } while (b--); var a; } expect_stdout: [ @@ -2208,7 +2208,7 @@ issue_3016_3_ie8: { var b = 1; do { console.log((a = void 0, a ? "FAIL" : a = "PASS")); - } while(b--); + } while (b--); var a; } expect_stdout: [ @@ -5141,3 +5141,45 @@ issue_4259: { } expect_stdout: "function" } + +issue_4261: { + options = { + inline: true, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + try { + throw 42; + } catch (e) { + (function() { + function f() { + e.p; + } + function g() { + while (f()); + } + (function() { + while (console.log(g())); + })(); + })(); + } + } + expect: { + try { + throw 42; + } catch (e) { + (function() { + function g() { + while (void e.p); + } + (function() { + while (console.log(g())); + })(); + })(); + } + } + expect_stdout: true +} |