diff --git a/lib/compress.js b/lib/compress.js index 911cf55439..010dcf46a4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1792,7 +1792,12 @@ merge(Compressor.prototype, { right: candidate.value }); } - candidate.write_only = false; + var assign = candidate; + while (assign.write_only) { + assign.write_only = false; + if (!(assign instanceof AST_Assign)) break; + assign = assign.right; + } return candidate; } // These node types have child nodes that execute sequentially, diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 2e85866e0e..1a21f513a7 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1681,3 +1681,25 @@ issue_4817: { expect_stdout: "function" node_version: ">=6" } + +issue_4854: { + options = { + collapse_vars: true, + inline: true, + side_effects: true, + unused: true, + } + input: { + console.log(function(a) { + (function(b = a = "foo") { + [] = "foo"; + })(); + a; + }()); + } + expect: { + console.log(void ([] = "foo")); + } + expect_stdout: "undefined" + node_version: ">=6" +}