We're implementing `super` in Firefox, and ran across this surprising behavior:

    class X {
        constructor() {
            Object.defineProperty(this, "prop", {
                configurable: true,
                writable: false,
                value: 1});
        }
        f() {
            super.prop = 2;  // overwrites non-writable property!
        }
    }

    var x = new X();
    x.f();
    assertEq(x.prop, 2);  // passes

In the spec, 9.1.9 step 4.d.i. is where `super.prop = 2` ends up, with
O=X.prototype.

Options:

1. Do nothing. Allow overwriting. It's a little weird, but this code
is pretty weird.

2. (post-ES6 of course) Add more "code" in 4.d.i. to perform a
[[GetOwnProperty]] and check.

-j
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to