archives

« Bugzilla Issues Index

#2491 — Changes to default constructor breaks "existing" code


The change to add a return to the default constructor broke some tests we have.

Before

construct(..args) {
super(...args);
}

Now

construct(..args) {
return super(...args);
}

The problem arises when we extend an old school "class" where the code does not explicitly set constructor.

function B() {}
B.prototype = { ... }
class C extends B {}
new C() instanceof C // false

The reason why this fails is that `B.prototype.constructor === Object` so `new C()` returns `Object()`.

The work around is to set `B.prototype.constructor = B` but I feel like the problem, adding return added solved, is smaller than the problem it introduces.


fixed in rev23 editor's draft

reverted back to the "before" definition


fixed in rev23 draft