diff --git a/lib/output.js b/lib/output.js index e2f7f060..080b3da8 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1179,6 +1179,17 @@ function OutputStream(options) { var def = self.definition(); output.print_name(def ? def.mangled_name || def.name : self.name); }); + DEFPRINT(AST_ObjectSymbol, function(self, output){ + var def = self.symbol.definition(); + if (def && def.mangled_name) { + output.print(self.symbol.name); + output.print(':'); + output.space(); + output.print(def.mangled_name); + } else { + output.print(self.symbol.name); + } + }); DEFPRINT(AST_Undefined, function(self, output){ output.print("void 0"); }); diff --git a/lib/parse.js b/lib/parse.js index fd870bbb..3d3eb664 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1410,9 +1410,6 @@ function parse($TEXT, options) { if (!is("punc", ":")) { // It's one of those object destructurings, the value is its own name - if (!S.in_parameters) { - croak("Invalid syntax", S.token.line, S.token.col); - } a.push(new AST_ObjectSymbol({ start: start, end: start, diff --git a/test/compress/destructuring.js b/test/compress/destructuring.js index 30fbbee8..6ea54ac1 100644 --- a/test/compress/destructuring.js +++ b/test/compress/destructuring.js @@ -32,3 +32,12 @@ destructuring_vardef_in_loops: { } expect_exact: "for(var[x,y]in pairs);for(var[a]=0;;);for(var{c}of cees);" } +destructuring_expressions: { + input: { + ({a, b}); + [{a}]; + f({x}); + } + expect_exact: "({a,b});[{a}];f({x});" +} +