From: Alex Lam S.L Date: Tue, 2 Mar 2021 09:39:34 +0000 (+0000) Subject: fix corner case in `inline` & `sequences` (#4718) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b1e05fd48afd9aceaa00cc621a8f6ac22c097398;p=UglifyJS.git fix corner case in `inline` & `sequences` (#4718) fixes #4717 --- diff --git a/lib/compress.js b/lib/compress.js index ad4c6809..e5e822af 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3126,7 +3126,7 @@ merge(Compressor.prototype, { if (prev) { if (stat instanceof AST_Exit) { if (stat.value || !in_async_generator(scope)) { - stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat)).transform(compressor); + stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat)).optimize(compressor); } } else if (stat instanceof AST_For) { if (!(stat.init instanceof AST_Definitions)) { diff --git a/test/compress/awaits.js b/test/compress/awaits.js index 77735991..974134c6 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -1246,3 +1246,37 @@ issue_4618: { expect_stdout: "function" node_version: ">=8" } + +issue_4717: { + options = { + inline: true, + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function() { + async function f() { + var a = function() { + await; + }(); + return "FAIL"; + } + return f(); + })().then(console.log).catch(function() { + console.log("PASS"); + }); + } + expect: { + (async function() { + return function() { + await; + }(), "FAIL"; + })().then(console.log).catch(function() { + console.log("PASS"); + }); + } + expect_stdout: "PASS" + node_version: ">=8" +}