On Apr 18, 2012, at 9:49 AM, Allen Wirfs-Brock wrote:
> ...
> var {b,b:{x,y}} = obj;  //fine because var declaration static semantics don't 
> disallow duplicates
> {  //avoid any conflicts with the preceeding var
>   let {b,b:{x,y}} = obj;  //block level duplicate declaration
> }
> 
> You might argue that the second b in the destructuring isn't actually 
> introducing a binding for b.  However,  syntactically it looks like one and 
> that is what the static semantic rule is driven off of.  If we allow that, we 
> would also be allowing:
>    let b=somethingElse;
>    let {b:{x,y})=obj;
> 
> If we want to allow that I'll have to some up with a different way to specify 
> the static semantics.

False alarm! Actually the above isn't correct.  The current spec draft actually 
does allow
   let {b,b:{x,y}};
but would issue an early error on
    let {b,b:{x:b,y}};

It is all in the static semantics production Bound Names in 12.2.4

The BoundNames of
     let {b}=obj
is ["b"]

The BoundNames of
   let {b:x} = obj
is ["x"]

The Bound Names of 
   let {b,b:{x,y}
is ["b","x","y"]

The Bound Names of 
   let {b,b:{x:b,y}}; 
is ["b","b","y"] and produces a duplicate declaration early error.  For a var 
declaration it would be allowd.

Sorry for the confusion.  I should have read my own spec. more carefully.

Allen




_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to