super.prop assignment can silently overwrite non-writable properties

Tom Van Cutsem tomvc.be at gmail.com
Wed Apr 22 06:39:22 UTC 2015


2015-04-21 22:15 GMT+02:00 Allen Wirfs-Brock <allen at wirfs-brock.com>:

>
> Yes, I considered that possibility in deciding upon the proposed change.
> The reason I error out if the Receiver property is an accessor is because I
> think the most likely way this scenario will occur is when that that access
> includes a `super.prop` assignment.  That would result in an infinite
> [[Set]] recursion.  For example:
>
> ```
> var y = {
>      __proto__: x,
>      set prop(v) {
>          // ...
>          super.prop = v;
>      }
> };
> y.prop = 42;
> ```
>

Assuming `x` here is the object where "prop" is bound to an accessor, can
you clarify how this would lead to an infinite recursion?

y.prop = 42; // 9.1.9 step 2 binds ownDesc to y's accessor, and calls it in
step 9
super.prop = v; // 9.1.9 step 2 binds ownDesc to x's accessor, and calls it
in step 9
x's setter then runs `v = n;` and the assignment terminates

I must be missing something?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150422/6b9b0c55/attachment.html>


More information about the es-discuss mailing list