[[Invoke]] and implicit method calls

Jason Orendorff jason.orendorff at gmail.com
Mon Sep 9 14:37:01 PDT 2013

There are some places in the spec where we might use [[Invoke]], but don't:

- implicit .toString() and .valueOf() calls
  (except Object.prototype.toLocaleString)
- implicit .toJSON() calls
- calls to Proxy handler methods

This seems unfortunate. Proxies with default handlers will work in
most places, thanks to the default [[Invoke]] trap, but not in ("" +
proxyObject) etc.

Is this still likely to change?

The apparent reason [[Invoke]] is not used in these places is that
they all do a [[Get]] first and check whether the property has a
callable value. But in the algorithm for yield*, in, we have
a similar check-before-calling situation, implemented using a
different idiom:

(step 4.d.viii in the last algorithm of
>     1. If HasProperty(iterator, "throw") is true, then
>         a. Let innerResult be the result of Invoke(iterator, "throw", (received)).

Having a [[GetMethod]] hook instead of an [[Invoke]] hook might make
it easier to use consistently everywhere.


More information about the es-discuss mailing list