diff --git a/lib/compress.js b/lib/compress.js index fb5bcb74..b767264c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -644,7 +644,14 @@ merge(Compressor.prototype, { fixed = save; return true; } - visit(node, fixed); + visit(node, fixed, function() { + var save_len = tw.stack.length; + for (var i = 0, len = scanner.stack.length - 1; i < len; i++) { + tw.stack.push(scanner.stack[i]); + } + node.walk(tw); + tw.stack.length = save_len; + }); return true; }); lhs.walk(scanner); @@ -678,10 +685,10 @@ merge(Compressor.prototype, { node.right.walk(tw); scan_declaration(tw, left, function() { return node.right; - }, function(sym, fixed) { + }, function(sym, fixed, walk) { if (!(sym instanceof AST_SymbolRef)) { mark_assignment_to_arguments(sym); - sym.walk(tw); + walk(); return; } var d = sym.definition(); @@ -696,7 +703,7 @@ merge(Compressor.prototype, { sym.fixed = d.fixed = fixed; sym.fixed.assigns = [ node ]; } else { - sym.walk(tw); + walk(); d.fixed = false; } }); diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 086790f0..9fd425d1 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -1844,3 +1844,25 @@ issue_4372_2: { expect_stdout: "PASS" node_version: ">=6" } + +issue_4383: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + console.log(function(a) { + [ a[0] ] = []; + return a.length; + }([])); + } + expect: { + console.log(function(a) { + [ a[0] ] = []; + return a.length; + }([])); + } + expect_stdout: "1" + node_version: ">=6" +}