This commit is contained in:
Jeremy Ashkenas 2011-01-10 23:09:21 -05:00
parent 45058dfa79
commit 44355f8eef
3 changed files with 12 additions and 2 deletions

View File

@ -1126,7 +1126,12 @@
value = this.value;
objects = this.variable.base.objects;
if (!(olen = objects.length)) {
return value.compile(o);
code = value.compile(o);
if (o.level >= LEVEL_OP) {
return "(" + code + ")";
} else {
return code;
}
}
isObject = this.variable.isObject();
if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) {

View File

@ -899,7 +899,9 @@ exports.Assign = class Assign extends Base
top = o.level is LEVEL_TOP
{value} = this
{objects} = @variable.base
return value.compile o unless olen = objects.length
unless olen = objects.length
code = value.compile o
return if o.level >= LEVEL_OP then "(#{code})" else code
isObject = @variable.isObject()
if top and olen is 1 and (obj = objects[0]) not instanceof Splat
# Unroll simplest cases: `{v} = x` -> `v = x.v`

View File

@ -247,6 +247,9 @@ test "destructuring assignment with context (@) properties", ->
eq d, obj.d
eq e, obj.e
test "#1024", ->
eq 2 * [] = 3 + 5, 16
#### Existential Assignment