From: Alex Lam S.L Date: Sun, 13 Dec 2020 16:03:44 +0000 (+0000) Subject: fix corner case in `dead_code` (#4378) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fcc40d0502a29e09a164ca04603db33b7dedfc3c;p=UglifyJS.git fix corner case in `dead_code` (#4378) fixes #4377 --- diff --git a/lib/compress.js b/lib/compress.js index db91155c..3e70f2eb 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3016,7 +3016,7 @@ merge(Compressor.prototype, { } function extract_declarations_from_unreachable_code(compressor, stat, target) { - if (!(stat instanceof AST_Definitions || stat instanceof AST_Defun)) { + if (!(stat instanceof AST_Definitions || is_defun(stat))) { AST_Node.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start); } var block; @@ -3032,7 +3032,7 @@ merge(Compressor.prototype, { } return true; } - if (node instanceof AST_Defun) { + if (is_defun(node)) { push(node); return true; } diff --git a/test/compress/async.js b/test/compress/async.js index 71df2449..8b7f596e 100644 --- a/test/compress/async.js +++ b/test/compress/async.js @@ -471,3 +471,28 @@ issue_4359: { expect_stdout: "PASS" node_version: ">=8" } + +issue_4377: { + options = { + dead_code: true, + inline: true, + side_effects: true, + } + input: { + console.log(typeof function() { + return function() { + f; + async function f() {} + return f(); + }(); + }().then); + } + expect: { + console.log(typeof function() { + return f(); + async function f() {} + }().then); + } + expect_stdout: "function" + node_version: ">=8" +}