Files
scriptc/tests/diagnostics/js-extends-poisoned-base.js
Chris Tate a7cd284944 Trap claims survive writes storage cannot serve; extending a rejected base reports at compile time
- trapDeclRootOf's written-binding decline now requires a mappable declared type: ordinary storage only buys anything when it compiles — an unmappable recursive call shape traded the compiling no-storage trap for a guaranteed SC2009 on a value that never exists
- bindingEverWritten skips statement-position writes whose RHS chain roots at an ambient-undefined name: that statement IS the RHS root's throw (lowerExprStatement's first claim) and never touches the target's storage, so it cannot justify the decline
- A poisoned base a top-level class extends flushes its deferred diagnostics eagerly (collectClassShape): the heritage evaluates at module init and the base's fence is the compiler's own — Node defines the base fine — so the deferred trap compiled a binary that refused at startup where Node runs; leaf and derived-only poisoned classes keep the JS deferral
- Fixtures: corpus 2632 (unmappable written trap binding) and 2633 (ambient-rooted rewrite), diagnostics js-extends-poisoned-base (the eager report names the base's real blocker), errors.test pins for both deferral edges that must NOT report eagerly; order-parity baselines recorded for the new entries
2026-07-24 15:03:30 -05:00

33 lines
984 B
JavaScript

// A JS class EXTENDING a base whose own collection fenced reports at
// COMPILE time: the derived statement evaluates its heritage at module
// init (top-level declarations always execute), and the base's fence is
// the compiler's own — Node defines the base fine and runs on — so a
// deferred trap there would be a manufactured divergence, not the
// Node-parity JS deferral is licensed by (classFieldSuperAccessibleJs2:
// the deferred binary printed nothing where Node prints five lines).
// The report names the BASE's real blocker, not the extends edge. Leaf and
// derived-only poisoned classes stay deferred (errors.test's shadowing pins).
class C {
constructor() {
this.foo = () => {
console.log("called arrow");
};
}
foo() {
console.log("called method");
}
}
class D extends C {
foo() {
console.log("SUPER:");
super.foo();
console.log("THIS:");
this.foo();
}
}
const obj = new D();
obj.foo();
D.prototype.foo.call(obj);