new [[HasProperty]] invariant for non-extensible objects

Raul-Sebastian Mihăilă raul.mihaila at gmail.com
Sun Mar 5 14:57:58 UTC 2017


By the time [[HasProperty]] (and `"foo" in p`) finishes, the property
doesn't exist anymore, therefore this invariant is not enforced. The
invariant is: if the property *exists* and the object is non-extensible,
[[HasProperty]] must return true. So, there's no guarantee it returns true
if you've deleted the property.

On Sun, Mar 5, 2017 at 4:45 PM, Oriol _ <oriol-bugzilla at hotmail.com> wrote:

> Yes, but the point is that if the property is removed, then
> [[HasProperty]] will return false, and thus the invariant can't be
> enforced, because an exotic object might behave like if the property was
> deleted under the hood.
>
> Since you say the invariant is enforced for exotic proxy objects, you may
> prefer a counterexample for these:
>
> ```js
> var target = Object.preventExtensions({foo: "bar"});
> var p = new Proxy(target, {
>   has: (target, prop) => !Reflect.deleteProperty(target, prop)
> });
>
> // Object is non-extensible
> Object.isExtensible(p); // false
>
> // foo is an observable own property
> !!Object.getOwnPropertyDescriptor(p, "foo"); // true
>
> // [[HasProperty]] returns false
> "foo" in p; // false
> ```
>
> -Oriol
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170305/0357f9fe/attachment-0001.html>


More information about the es-discuss mailing list