diff --git a/lib/compress.js b/lib/compress.js index 76785f46..c63a64c6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1922,6 +1922,8 @@ merge(Compressor.prototype, { else if (node.names[i] instanceof AST_Expansion) { if (node.names[i].expression instanceof AST_Symbol) { initializations.add(node.names[i].expression.name, destructuring_value); + } else if (node.names[i].expression instanceof AST_Destructuring) { + node.names[i].expression.walk(tw); } else { throw new Error(string_template("Can't handle expansion of type: {type}", { type: Object.getPrototypeOf(node.names[i].expression).TYPE diff --git a/test/compress/destructuring.js b/test/compress/destructuring.js index 313d47d7..8603a38b 100644 --- a/test/compress/destructuring.js +++ b/test/compress/destructuring.js @@ -151,8 +151,12 @@ destructuring_remove_unused_1: { function e() { var unused = "foo"; var a = [1, 2, 3, 4, 5]; + var x = [[1, 2, 3]]; + var y = {h: 1}; var [b, ...c] = a; - f(b, c); + var [...[e, f]] = x; + var [...{g: h}] = y; + f(b, c, e, f, g); } } expect: { @@ -178,8 +182,12 @@ destructuring_remove_unused_1: { } function e() { var a = [1, 2, 3, 4, 5]; + var x = [[1, 2, 3]]; + var y = {h: 1}; var [b, ...c] = a; - f(b, c); + var [...[e, f]] = x; + var [...{g: h}] = y; + f(b, c, e, f, g); } } }