diff --git a/lib/nodes.js b/lib/nodes.js index d8037edd..8172d196 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -756,9 +756,10 @@ // object literals to a value. Peeks at their properties to assign inner names. // See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring compile_pattern_match: function compile_pattern_match(o) { - var _a, _b, access_class, assigns, code, i, idx, obj, val, val_var; + var _a, _b, access_class, assigns, code, i, idx, obj, val, val_var, value; val_var = o.scope.free_variable(); - assigns = [this.idt() + val_var + ' = ' + this.value.compile(o) + ';']; + value = this.value.is_statement() ? ClosureNode.wrap(this.value) : this.value; + assigns = [this.idt() + val_var + ' = ' + value.compile(o) + ';']; o.top = true; o.as_statement = true; _a = this.variable.base.objects; diff --git a/src/nodes.coffee b/src/nodes.coffee index 3df8edc8..87425ead 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -604,7 +604,8 @@ AssignNode: exports.AssignNode: inherit BaseNode, { # See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring compile_pattern_match: (o) -> val_var: o.scope.free_variable() - assigns: [@idt() + val_var + ' = ' + @value.compile(o) + ';'] + value: if @value.is_statement() then ClosureNode.wrap(@value) else @value + assigns: [@idt() + val_var + ' = ' + value.compile(o) + ';'] o.top: true o.as_statement: true for obj, i in @variable.base.objects