Re: Proxies: wrong receiver used in default set trap

2012-12-21 Thread Andreas Rossberg
On 21 December 2012 03:00, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: I'm not sure I follow. In my understanding, the original Receiver is only needed for traps that involve prototype-chain walking and are thus |this|-sensitive. That

Re: Proxies: wrong receiver used in default set trap

2012-12-21 Thread Tom Van Cutsem
2012/12/21 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: 2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: If target.baz is a writable data property proxy.baz = 42 will eventually call

Re: Proxies: wrong receiver used in default set trap

2012-12-21 Thread Allen Wirfs-Brock
On Dec 21, 2012, at 5:15 AM, Andreas Rossberg wrote: On 21 December 2012 03:00, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: I'm not sure I follow. In my understanding, the original Receiver is only needed for traps that involve

Re: Proxies: wrong receiver used in default set trap

2012-12-21 Thread Allen Wirfs-Brock
On Dec 21, 2012, at 7:01 AM, Tom Van Cutsem wrote: 2012/12/21 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: 2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: If target.baz is a writable

Re: Proxies: wrong receiver used in default set trap

2012-12-21 Thread Tom Van Cutsem
2012/12/21 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 21, 2012, at 7:01 AM, Tom Van Cutsem wrote: I think that with the provision of the Handler API, we provide Proxy authors with the same benefits than if we would add delegation to the ES6 built-ins, without any required changes to

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Tom Van Cutsem
[+jwalden] 2012/12/19 Allen Wirfs-Brock al...@wirfs-brock.com Consider: let target = {foo() {return this}}; let proxy = Proxy(target, {}); As currently spec'ed. proxy.foo() is going to return proxy rather than target. That's because, proxy.foo evaluates to a Reference whose base is

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Tom Van Cutsem
2012/12/19 Allen Wirfs-Brock al...@wirfs-brock.com If we make the Option A change that seems right for [[GetP]]/[[SetP]] then we will have an inconsistency between the this value used for a method invoked as proxy.foo() and a accessor invoked as proxy.bar To clarify, if we apply the fix to

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Andreas Rossberg
On 20 December 2012 11:09, Tom Van Cutsem tomvc...@gmail.com wrote: Currently, that test is performed in step 5.b. by testing whether the current object we are visiting in the proto chain O is the Receiver object. At first sight, this is a rather weird way of deciding between update vs.

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread David Bruant
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

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Andreas Rossberg rossb...@google.com On 20 December 2012 11:09, Tom Van Cutsem tomvc...@gmail.com wrote: Currently, that test is performed in step 5.b. by testing whether the current object we are visiting in the proto chain O is the Receiver object. At first sight, this is a

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Allen Wirfs-Brock
On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: 2012/12/19 Allen Wirfs-Brock al...@wirfs-brock.com If we make the Option A change that seems right for [[GetP]]/[[SetP]] then we will have an inconsistency between the this value used for a method invoked as proxy.foo() and a accessor

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: If target.baz is a writable data property proxy.baz = 42 will eventually call Object.defineProperty(proxy, 'baz', {value:42}) (and *not* Object.defineProperty(proxy, 'baz',

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com Yes, here is the new step 5 as I have just updated it in my spec. draft (ignore the 1, it's really 5) 1. If IsDataDescriptor(*ownDesc*) is *true*, then 1. If *ownDesc*.[[Writable]] is *false*, return *false*. 2. If

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Allen Wirfs-Brock
On Dec 20, 2012, at 12:12 PM, Tom Van Cutsem wrote: 2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com Yes, here is the new step 5 as I have just updated it in my spec. draft (ignore the 1, it's really 5) If IsDataDescriptor(ownDesc) is true, then If ownDesc.[[Writable]] is false, return

Re: Proxies: wrong receiver used in default set trap

2012-12-20 Thread Allen Wirfs-Brock
On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: 2012/12/20 Allen Wirfs-Brock al...@wirfs-brock.com On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: If target.baz is a writable data property proxy.baz = 42 will eventually call Object.defineProperty(proxy, 'baz', {value:42}) (and

Re: Proxies: wrong receiver used in default set trap

2012-12-19 Thread Andreas Rossberg
On 18 December 2012 22:56, Tom Van Cutsem tomvc...@gmail.com wrote: Option B: Address point 2) directly by changing the test that determines property addition versus property update inside Reflect.set (i.e. the [[SetP]] internal method of objects) so that the algorithm no longer tests whether

Re: Proxies: wrong receiver used in default set trap

2012-12-19 Thread Tom Van Cutsem
2012/12/19 Allen Wirfs-Brock al...@wirfs-brock.com I think it has to be A, for consistency with [[Call]]. Note that when [[Call]] is directly forwarded to the target, the this value is set to target. It wouldn't be self-consistent if directly forwarded foo.access and foo.method() invocations

Re: Proxies: wrong receiver used in default set trap

2012-12-19 Thread Tom Van Cutsem
2012/12/19 Andreas Rossberg rossb...@google.com So it has to be A. (Or the definition of Reflect.set has to change. I don't have much love for the case distinction in there anyway. But it's probably a necessary consequence of the somewhat incoherent property assignment model we are stuck

Re: Proxies: wrong receiver used in default set trap

2012-12-19 Thread Allen Wirfs-Brock
On Dec 19, 2012, at 2:01 AM, Tom Van Cutsem wrote: 2012/12/19 Allen Wirfs-Brock al...@wirfs-brock.com I think it has to be A, for consistency with [[Call]]. Note that when [[Call]] is directly forwarded to the target, the this value is set to target. It wouldn't be self-consistent if

Re: Proxies: wrong receiver used in default set trap

2012-12-19 Thread Brandon Benvie
Andrea Giammarchi has pointed out in the past that it's not possible to fully shim __noSuchMethod__ because of this same issue. Perhaps introducing a [[CallProperty]] is not such a bad idea. On Wednesday, December 19, 2012, Allen Wirfs-Brock wrote: I'm not sure there is an easy fix that

Proxies: wrong receiver used in default set trap

2012-12-18 Thread Tom Van Cutsem
Hi, Someone recently reported an issue [1] while using my harmony-reflect shim for direct proxies. The fix probably requires a change in the proxy specification. I'm unsure how to resolve it, so I thought I'd bring it to the list. The issue is as follows: consider a proxy with an empty handler:

Re: Proxies: wrong receiver used in default set trap

2012-12-18 Thread Allen Wirfs-Brock
I think it has to be A, for consistency with [[Call]]. Note that when [[Call]] is directly forwarded to the target, the this value is set to target. It wouldn't be self-consistent if directly forwarded foo.access and foo.method() invocations used different this values. I assume that by proxy