diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-04 20:49:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 04:49:37 +0800 |
commit | da24dfb59ea9c67d98f39daab4299b75c15978ea (patch) | |
tree | 1bfe2aa0bb32ed5a577327a1476f95d0014af877 /test/compress | |
parent | a2f27c7640fee2c981b49ee484a37e1721622bb3 (diff) | |
download | tracifyjs-da24dfb59ea9c67d98f39daab4299b75c15978ea.tar.gz tracifyjs-da24dfb59ea9c67d98f39daab4299b75c15978ea.zip |
fix corner cases with function inlining (#4613)
fixes #4612
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/functions.js | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index e0a4ee72..5de05f61 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -5283,3 +5283,127 @@ issue_4471: { "PASS", ] } + +issue_4612_1: { + options = { + evaluate: true, + inline: true, + reduce_vars: true, + side_effects: true, + unused: true, + } + input: { + console.log(function() { + function f() { + return g(); + } + function g(a) { + return a || f(); + } + return g("PASS"); + }()); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" +} + +issue_4612_2: { + options = { + evaluate: true, + inline: true, + reduce_vars: true, + side_effects: true, + unused: true, + } + input: { + console.log(function() { + function fn() { + return h(); + } + function g() { + return fn(); + } + function h(a) { + return a || fn(); + } + return h("PASS"); + }()); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" +} + +issue_4612_3: { + options = { + inline: true, + reduce_vars: true, + } + input: { + console.log(typeof function() { + return g(); + function f() { + return g; + } + function g() { + { + return f; + } + } + }()); + } + expect: { + console.log(typeof function() { + return g(); + function f() { + return g; + } + function g() { + return f; + } + }()); + } + expect_stdout: "function" +} + +issue_4612_4: { + options = { + booleans: true, + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function() { + function f() { + return h(); + } + function g() { + { + return h(); + } + } + function h() { + { + return g(); + } + } + }()); + } + expect: { + console.log(function() { + function f() { + return h(); + } + function g() { + return h(); + } + function h() { + return g(); + } + }()); + } + expect_stdout: "undefined" +} |