Proxies: wrong "receiver" used in default "set" trap

David Bruant bruant.d at gmail.com
Thu Dec 20 03:53:18 PST 2012


Le 20/12/2012 11:09, Tom Van Cutsem a écrit :
> (...)
> The right fix (at least, it feels like the obvious right fix to me), 
> is not to test whether O === Receiver, but rather just let the 
> algorithm explicitly test whether the Receiver object already defines 
> an own property with key P, to decide between update vs. addition:
>
> replace step 5.b with:
> 5.b Let existingDesc be the result of calling the [[GetOwnProperty]] 
> internal method of Receiver with argument P.
> 5.c If existingDesc is not undefined, then
>   ... // same steps as before
>
> Now, for normal objects, this test is redundant since existingDesc and 
> ownDesc will denote the same property. But that redundancy is 
> harmless, just as in ES5 [[Put]] it was redundant to call both 
> [[GetProperty]] and [[GetOwnProperty]] on the same object. In the fast 
> path, engines will not follow this algorithm anyway. If Receiver is a 
> proxy, then the difference matters and the proxy will be able to 
> intercept the call to [[GetOwnProperty]] (which is what makes this 
> revised algorithm work in the presence of proxies).
A note in the spec to explain this would probably be a good idea, 
because it's a very subtle difference.

David


More information about the es-discuss mailing list