mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-14 02:54:02 +08:00
A base constructor that returns an instance of its class gets a result slot, and super() from a subclass refused. three.js's Color constructor ends in `return this.set(r, g, b)`, where set returns this, so every construction of Color4 (`super(r, g, b)` during three.webgpu.js's module initialization) threw the refusal, while Node constructs the subclass's own instance. In JavaScript, super() into such a class now calls a per-subclass helper after the base constructor: it reads and clears the base's result slot, and refuses at run time only when the base returned an instance other than the subclass's this, where Node would rebind it. TypeScript subclasses keep the compile-time refusal.