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

2012-12-21 Thread Tom Van Cutsem
2012/12/21 Allen Wirfs-Brock > > 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 existing internal m

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 > > On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: > >> 2012/12/20 Allen Wirfs-Brock >> >> On Dec 20, 2012, at 2:21 AM, Tom Van Cutsem wrote: >>> If target.baz is a writable data property >>> proxy.baz = 4

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 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 walki

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

2012-12-21 Thread Tom Van Cutsem
2012/12/21 Allen Wirfs-Brock > > On Dec 20, 2012, at 12:07 PM, Tom Van Cutsem wrote: > > 2012/12/20 Allen Wirfs-Brock > >> >> 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, 'ba

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

2012-12-21 Thread Andreas Rossberg
On 21 December 2012 03:00, Allen Wirfs-Brock 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 would be just [[G

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 > > 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.

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 > 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 false. > If Type(

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

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Allen Wirfs-Brock > 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 Type(*Receiver*) is not Ob

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

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Allen Wirfs-Brock > > 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', > {value:42,enumerable:true,wr

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

2012-12-20 Thread Allen Wirfs-Brock
below On Dec 20, 2012, at 2:09 AM, Tom Van Cutsem wrote: > [+jwalden] > > 2012/12/19 Allen Wirfs-Brock > ... > > 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 ra

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 > 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

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

2012-12-20 Thread Tom Van Cutsem
2012/12/20 Andreas Rossberg > On 20 December 2012 11:09, Tom Van Cutsem 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 bet

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 be

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

2012-12-20 Thread Andreas Rossberg
On 20 December 2012 11:09, Tom Van Cutsem 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. addition. We can g

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

2012-12-20 Thread Tom Van Cutsem
2012/12/19 Allen Wirfs-Brock > 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 [[SetP]] described

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

2012-12-20 Thread Tom Van Cutsem
[+jwalden] 2012/12/19 Allen Wirfs-Brock > 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 proxy. > Getti

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 doesn'

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 > 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

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

2012-12-19 Thread Tom Van Cutsem
2012/12/19 Andreas Rossberg > 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 with.) > Indeed. To

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

2012-12-19 Thread Tom Van Cutsem
2012/12/19 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 th

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

2012-12-19 Thread Andreas Rossberg
On 18 December 2012 22:56, Tom Van Cutsem 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 > target === r

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

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: