diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-18 08:15:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-18 16:15:44 +0800 |
commit | a7bcd4d613b73ff43300bf9053ce466735a7f81a (patch) | |
tree | 10d04fc5ed2a9a80218158ea917856150122905a /test/compress | |
parent | 6a2bda52f332b0c39f1a5f81583cc5c63f437f4c (diff) | |
download | tracifyjs-a7bcd4d613b73ff43300bf9053ce466735a7f81a.tar.gz tracifyjs-a7bcd4d613b73ff43300bf9053ce466735a7f81a.zip |
fix corner case in `inline` (#4660)
fixes #4659
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/functions.js | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index 7e2b45db..f521433d 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -5436,3 +5436,125 @@ issue_4655: { } expect_stdout: "PASS" } + +issue_4659_1: { + options = { + inline: true, + reduce_vars: true, + } + input: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + f && f(); + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + f && a++; + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect_stdout: "1" +} + +issue_4659_2: { + options = { + inline: true, + reduce_vars: true, + } + input: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + (function() { + f && f(); + })(); + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + void (f && a++); + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect_stdout: "1" +} + +issue_4659_3: { + options = { + inline: true, + reduce_vars: true, + unused: true, + } + input: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + function g() { + while (!console); + } + g(f && f()); + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect: { + var a = 0; + (function() { + function f() { + return a++; + } + (function() { + (function() { + while (!console); + })(f && a++); + (function() { + var a = console && a; + })(); + })(); + })(); + console.log(a); + } + expect_stdout: "1" +} |