Issue when subclassing a bound function used as constructor

# Claude Pache (7 years ago)
let C // be some constructor
let D = C.bind(obj, a, b)

Thanks to the carefully designed D.[[Construct]] internal method, the following expressions are equivalent:

new D(...args)
new C(a, b, ...args)

Consider now:

class E extends D {
    contructor(...args) {
        super(...args)
    }
}

As I understand, super(...args) calls D.[[Call]](this, args), which in turn calls C.[[Call]](obj, [a, b, ...args]). But what we probably want here, is C.[[Call]](this, [a, b, ...args]).

I am missing something or is there an issue?

—Claude

# Allen Wirfs-Brock (7 years ago)

Hmm....

On Jun 26, 2014, at 9:57 AM, Claude Pache wrote:

let C be some constructor
let D = C.bind(obj, a, b)

Thanks to the carefully designed D.[[Construct]] internal method, the following expressions are equivalent:

Hmm....and showing that perhaps is isn't so easy to get rid of [[Construct]]

new D(...args)
new C(a, b, ...args)

Consider now:

class E extends D {
    contructor(...args) {
        super(...args)
    }
}

As I understand, super(...args) calls D.[[Call]](this, args), which in turn calls C.[[Call]](obj, [a, b, ...args]). But what we probably want here, is C.[[Call]](this, [a, b, ...args]).

I am missing something or is there an issue?

Yes, this analysis is correct and an unfortunate effect of F.p.bind conflating the binding of the this value with partial application of the arguments.

I don't see anyway around this given the current designs for classes and for bound functions.

Given that such a bound function can't really be super invoked as an instance initializer perhaps we should make an an error for a class definition extends clause to evaluate to a bound function. We alway throw, it the "superclass" is not a constructor so adding an additional check to see whether the "superclass" is bound would be a small addition.