getPrototypeOf invariant

Mark S. Miller erights at
Thu Oct 4 08:07:35 PDT 2012

On Thu, Oct 4, 2012 at 4:36 AM, David Bruant <bruant.d at> wrote:

> Hi,
> Currently, the wiki says:
> "Invariant check: check whether the target’s prototype and the trap result
> are identical."
> If the trap can only report one value, there is almost no point in having
> a trap.

General principle: even when the successful result of the trap must be
identical to that same operation as performed on the target, making it a
trap has two uses and a corresponding hazard:

* It allows the operation to be aborted by throwing an exception.
* It allows the target to be modified first, in anticipation of the target
being queried at the end of the trap.

The hazard which is necessarily implied by these is that it allows
interleaving of user code within an operation that would otherwise have
been safe against interleaving. That's one of the reasons why we don't trap
everything with this "identical" feature, for example, === and typeof.

> A getPrototypeOf trap allows for proxies to potentially simulate __proto__
> in a platform where it wouldn't exist natively. It only does if it's
> possible to freely report any Object (as per ES5.1 - 8.6) or null.
> Or maybe what was meant was only when the target is non-extensible?
> David
> _______________________________________________
> es-discuss mailing list
> es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list