From: Alex Lam S.L Date: Thu, 21 May 2020 14:05:31 +0000 (+0100) Subject: fix corner case in `inline` (#3915) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=aeb9ea5ac22fe37d0a74bb8cacd6edfa1ae9ef8c;p=UglifyJS.git fix corner case in `inline` (#3915) fixes #3911 --- diff --git a/lib/compress.js b/lib/compress.js index 006b635a..06d04cc5 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -6234,9 +6234,9 @@ merge(Compressor.prototype, { && !fn.uses_arguments && !fn.pinned() && !(fn.name && fn instanceof AST_Function) - && (value = can_flatten_body(stat)) && (exp === fn || !recursive_ref(compressor, def = exp.definition()) && fn.is_constant_expression(exp.scope)) + && (value = can_flatten_body(stat)) && !fn.contains_this()) { if (can_substitute_directly()) { var args = self.args.slice(); diff --git a/test/compress/functions.js b/test/compress/functions.js index db5466ea..7ad6ff03 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -4680,3 +4680,28 @@ issue_3852: { } expect_stdout: "PASS" } + +issue_3911: { + options = { + collapse_vars: true, + conditionals: true, + inline: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function f() { + return function() { + if (a) (a++, b += a); + f(); + }; + } + var a = f, b; + console.log("PASS"); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" +}