super.prop assignment can silently overwrite non-writable properties

Caitlin Potter caitpotter88 at gmail.com
Mon Apr 20 18:35:59 UTC 2015


>Uh, yes. And it should set `X.prototype.prop` to `2`, because that still is writable and not affected by the attributes of `x.prop`.
> So I would expect `x.prop` to still have the value `1`, shadowing the prototype property.

I made this mistake as well, jorendorff@ pointed out that SuperProperty references use “this” as the receiver for [[Set]], so it will actually overwrite the value rather than setting it on X.prototype.

In the example provided, 5.e.ii is reached, and OrdinaryDefineOwnProperty() should return false and throw. This appears to be V8’s behaviour when testing in Canary (44.0.2375.0)


> On Apr 20, 2015, at 2:25 PM, Bergi <a.d.bergi at web.de> wrote:
> 
> Jason Orendorff schrieb:
> > […] `super.prop = 2` ends up with O=X.prototype.
> 
> Uh, yes. And it should set `X.prototype.prop` to `2`, because that still is writable and not affected by the attributes of `x.prop`. So I would expect `x.prop` to still have the value `1`, shadowing the prototype property.
> 
> (at least that's how I understood super references)
> 
> Bergi
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150420/78ccd34e/attachment.html>


More information about the es-discuss mailing list