fixing patternmatched assigns within assigns within calls

This commit is contained in:
Jeremy Ashkenas 2010-02-25 07:28:48 -05:00
parent b32a60585b
commit 4ed51536bb
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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