It turns out Safari uses the context of the callee to decide which global
object to use as receiver, so cross-context calls will use the called
function's context's global object.

This would allow us to implement this by passing undefined and moving the
conversion into the start of non-strict non-native functions.

/L

On Wed, May 4, 2011 at 09:39, <[email protected]> wrote:

> Status: Accepted
> Owner: ----
> Labels: Type-Bug Priority-Medium ES5
>
> New issue 1365 by [email protected]: Calling functions through
> variables doesn't use undefined as receiver.
> http://code.google.com/p/v8/issues/detail?id=1365
>
> When you call a function through an environment variable, e.g.
>  var v = Object.prototype.valueOf
>  v();  // <-- this call
> the ES5 specification says that the this-value of the call should be the
> undefined value. We optimistically convert that to the global object, even
> for strict mode functions and builtin functions.
>
> The above call should throw an exception (attempt to use ToObject on
> undefined) but instead returns the global object.
> Ditto for
>  "use strict";
>  function foo() { return this; }
>  foo();  // returns global object
>
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
>



-- 
Lasse R.H. Nielsen
[email protected]
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K -
Denmark - CVR nr. 28 86 69 84

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to