Re: variable declarations shadowing named properties on window

Boris Zbarsky:
> In any case, the updated text says that if HasBinding returns true then
> the implementation should call [[GetOwnProperty]] on the global. If this
> returns undefined, then [[DefineOwnProperty]] is called on the global
> with the property descriptor: {[[Value]]: undefined, [[Writable]]: true,
> [[Enumerable]]: true , [[Configurable]]: configurableBindings }.
>
> So now to make var shadow some property that property needs to either
> return false from HasBinding or return undefined from [[GetOwnProperty]].

Only if we want to keep them on window.  If we're happy to move them to 
the prototype then we're safe, I believe.

> Cameron, can GSP properties return undefined from [[GetOwnProperty]] but
> still do what they should for window.foo and bareword lookups without
> other things elsewhere breaking?

They can for window.foo but not for bareword lookups.  window.foo will 
do a [[Get]], and we could have that return the frame while 
[[GetOwnProperty]] returns undefined.  That breaks barewords, though, 
which definitely do use HasBinding and so [[GetOwnProperty]] to 
determine if the reference can be resolved or not.

Received on Friday, 6 January 2012 03:09:47 UTC