From da24dfb59ea9c67d98f39daab4299b75c15978ea Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 4 Feb 2021 20:49:37 +0000 Subject: fix corner cases with function inlining (#4613) fixes #4612 --- test/compress/functions.js | 124 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) (limited to 'test/compress/functions.js') 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" +} -- cgit v1.2.3