descriptors and not only own properties gotcha

Gary Guo nbdd0121 at hotmail.com
Sat Dec 20 06:00:32 PST 2014


On Wed Dec 17 10:30:03 PST 2014, Andrea Giammarchi  wrote:
>This would already fix the `Object.prototype.get` or `.set` case since I
>believe nobody ever used an inherited `value` property on purpose for
>descriptors ... or is it?

I agree that nobody will use an inherited 'value' property, however, I think the inherited 'get' or 'set' property should be weighted equally as 'value' property, despite the fact that it is not usual to do that. I don't know whether it is a bug or it is intended, the current version of ECMAScript (5.1) seems to use [[HasProperty]] instead of [[GetOwnProperty]], so the case you talked about is actually valid in the specification. My suggestion is that maybe we should change the specification from using property to using own property *only*.

Excerpted From ECMAScript 5.1 8.10.5

```
5. If the result of calling the [[HasProperty]] internal method of Obj with argument "value" is true, then
a. Let value be the result of calling the [[Get]] internal method of Obj with argument ¨Dvalue¡¬.
b. Set the [[Value]] field of desc to value.
```

We can change it into

```
5. If the result of calling the [[GetOwnProperty]] internal method of Obj with argument "value" is not undefined, then
a. Let value be the result of calling the [[Get]] internal method of Obj with argument ¨Dvalue.
b. Set the [[Value]] field of desc to value.
```

I believe such a change will not make a big difference (since a descriptor has only 4 properties, it is not essential to use prototyping) 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141220/f46620e3/attachment.html>


More information about the es-discuss mailing list