From: Alex Lam S.L Date: Tue, 26 Dec 2017 10:56:59 +0000 (+0800) Subject: suppress `inline` within substituted `AST_Scope` (#2658) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7f342cb3e3abd3e39b18e62a2e9d6b8020d82773;p=UglifyJS.git suppress `inline` within substituted `AST_Scope` (#2658) fixes #2657 --- diff --git a/lib/compress.js b/lib/compress.js index 8df6bbd5..bb355423 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3982,7 +3982,7 @@ merge(Compressor.prototype, { do { scope = compressor.parent(++level); if (scope instanceof AST_SymbolRef) { - scope = scope.fixed_value(); + if (scope.fixed_value() instanceof AST_Scope) return false; } else if (scope instanceof AST_Catch) { catches[scope.argname.name] = true; } diff --git a/test/compress/functions.js b/test/compress/functions.js index 02b4ab39..7f35de76 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -1447,3 +1447,33 @@ recursive_inline: { } expect: {} } + +issue_2657: { + options = { + inline: true, + reduce_vars: true, + sequences: true, + unused: true, + } + input: { + "use strict"; + console.log(function f() { + return h; + function g(b) { + return b || b(); + } + function h(a) { + g(a); + return a; + } + }()(42)); + } + expect: { + "use strict"; + console.log(function(a) { + return b = a, b || b(), a; + var b; + }(42)); + } + expect_stdout: "42" +}