defineProperty invariants

Tom Van Cutsem at
Fri Oct 5 06:05:18 PDT 2012


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

> 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

> 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.

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

More information about the es-discuss mailing list