defineProperty invariants

Tom Van Cutsem tomvc.be at gmail.com
Fri Oct 5 06:05:18 PDT 2012


Hi,

2012/10/4 David Bruant <bruant.d at gmail.com>

> Hi,
>
> I think it's the dual of the getOwnPropertyDescriptor invariant I talked
> about recently.
>

Yep. That's exactly it. I'll patch the spec.


> I think the invariant should be:
> ToBoolean(definePropertyTrapOutput) === true => (descArgument.configurable
> === targetDesc.configurable)
>

I would formulate it as:
ToBoolean(definePropertyTrapOutput) === true && descArgument.configurable
=== false => targetDesc !== undefined && targetDesc.configurable === false

(in words: if Object.defineProperty succeeds for a non-configurable
property, then the property must exist on the target and also be
non-configurable)


> Basically, it says that if the operation succeeded, the new target
> descriptor and the descriptor on the target after the trap call are the
> same.
>

With the minor detail that defining a configurable property can succeed
without the property having to exist on the target at all.


> Do we want invariants regarding when ToBoolean(definePropertyTrapOutput)
> is false?
>

I don't think that is necessary: if the trap returns false,
Object.defineProperty will throw anyway. Trying to enforce some invariant
would only lead to the same effect.

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121005/341ff79a/attachment.html>


More information about the es-discuss mailing list