Open ljharb opened 1 month ago
Specifically, right now from the perspective of a creator of Proxies there are four kinds of things in the world: primitives (which can't be proxied), functions, objects, and arrays. Arrays are there only because of the Proxy-piercing behavior of isArray
. I don't think we should make that list any larger, especially for some random type that isn't particularly foundational.
There's more than that - there's "objects" and "objects with internal slots or private fields or closure-based receiver identity checking" - but I don't think that weakens your argument.
Proxies don't need to distinguish between those things when choosing their target unless they're forwarding some operations to the target rather than implementing all the traps. The happy path for a Proxy is that the target is unrelated to the object that the Proxy is pretending to be.
https://github.com/tc39/proposal-is-error/issues/7#issuecomment-2221669917
On the question of proxy piercing, this would make
Object.prototype.toString
conflict withError.isError
(since only isError will pierce), unlikeArray.isArray
which pierces in both places. I don't think that's a good idea.
I find this to be an additional strong argument against proxy piercing.
I've put up #11 which removes proxy piercing.
Array.isArray pierces Proxies. This is widely regarded as weird. The current proposal pierces in the same way.
@bakkot has expressed a constraint that prior to stage 2.7, the proxy piercing be removed.
I suspect @erights @mhofman @kriskowal @gibson042 will have thoughts. Please express them here :-)