[[CanPut]] semantics
Brendan Eich
brendan at mozilla.org
Fri Sep 14 19:05:50 PDT 2012
Oliver Hunt wrote:
> My reading of [[CanPut]] implies that it only checks a single level of the prototype chain. This seems incorrect to me but I thought I'd check whether it is in fact intentional, or whether it's a spec bug.
See step 4 and later.
/be
ES5.1 8.12.4 [[CanPut]] (P)
When the [[CanPut]] internal method of O is called with property name P,
the following steps are taken:
1. Let desc be the result of calling the [[GetOwnProperty]] internal
method of O with argument P.
2. If desc is not undefined, then
a. If IsAccessorDescriptor(desc) is true, then
i. If desc.[[Set]] is undefined, then return false.
ii. Else return true.
b. Else, desc must be a DataDescriptor so return the value of
desc.[[Writable]].
3. Let proto be the [[Prototype]] internal property of O.
4. If proto is null, then return the value of the [[Extensible]]
internal property of O.
5. Let inherited be the result of calling the [[GetProperty]] internal
method of proto with property name P.
6. If inherited is undefined, return the value of the [[Extensible]]
internal property of O.
7. If IsAccessorDescriptor(inherited) is true, then
a. If inherited.[[Set]] is undefined, then return false.
b. Else return true.
8. Else, inherited must be a DataDescriptor
a. If the [[Extensible]] internal property of O is false, return false.
b. Else return the value of inherited.[[Writable]].
Host objects may define additional constraints upon [[Put]] operations.
If possible, host objects should not
allow [[Put]] operations in situations where this definition of
[[CanPut]] returns false.
More information about the es-discuss
mailing list