diff --git a/lib/compress.js b/lib/compress.js index 8e135e2df7..728523652c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4094,7 +4094,7 @@ Compressor.prototype.compress = function(node) { changed = true; } } - var loop = in_loop && in_try && in_try.bfinally ? "try" : in_loop; + var loop = in_loop && in_try ? "try" : in_loop; for (; index >= 0; index--) { var inlined = statements[index].try_inline(compressor, block_scope, true, loop); if (!inlined) continue; diff --git a/test/compress/functions.js b/test/compress/functions.js index 3d8fc477a1..42a2acf995 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -8997,3 +8997,82 @@ issue_5885: { } expect_stdout: "NaNfoo" } + +issue_5895_1: { + options = { + inline: true, + unused: true, + } + input: { + (function() { + for (var a in [ 1, 2 ]) + try { + return function() { + var b; + b[b = 42]; + while (!console); + }(); + } catch (e) { + console.log("foo"); + } + })(); + } + expect: { + (function() { + for (var a in [ 1, 2 ]) + try { + b = void 0; + var b; + b[b = 42]; + while (!console); + return; + } catch (e) { + console.log("foo"); + } + })(); + } + expect_stdout: [ + "foo", + "foo", + ] +} + +issue_5895_2: { + options = { + inline: true, + unused: true, + } + input: { + (function() { + for (var a in [ 1, 2 ]) + try { + return function() { + (function f(b) { + b[b = 42]; + })(); + while (!console); + }(); + } catch (e) { + console.log("foo"); + } + })(); + } + expect: { + (function() { + for (var a in [ 1, 2 ]) + try { + b = void 0; + void b[b = 42]; + var b; + while (!console); + return; + } catch (e) { + console.log("foo"); + } + })(); + } + expect_stdout: [ + "foo", + "foo", + ] +}