archives

« Bugzilla Issues Index

#208 — Destructuring should work with LeftHandSideExpression


SpiderMonkey allows a LeftHandSideExpression and not just a SingleNameBinding on the right hand side of a BindingProperty. The following should work:

var object = {};
({x: object.y}) = {x: 42};
print(object.y); // 42


The rev 3 draft does allow LeftHandSideExpression to appear as the target of destructuring assignment. See 11.13

It is only binding forms (let, const, var, parameters, etc.) defined in 12.2.4 that require a single name. I believe that this is a valid restriction on binding forms. I don't think we want binding forms to act as as arbitrary assignment statements.


The draft looks fine. I didn't see the ArrayAssignmentPattern forms.