mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
A JavaScript source reading Number.prototype got undefined: the checker types it with the wrapper interface, the type mapper maps that interface to f64, and nothing built a prototype object. The read now lowers, in JavaScript sources only, to dyn.builtinPrototype, served by a new gated unit that builds the two prototype objects the way the language defines them: an ordinary object on Object.prototype carrying the kind's methods as non-enumerable, writable, configurable data properties, answered from one box per thread so repeated reads are the same object. A method runs on the prototype's primitive (+0 / false), which is its [[PrimitiveValue]] in Node. Two follow-on gaps the read exposed are fixed with it: narrowing no longer extracts a scalar from a prototype value, and a call through the prototype no longer takes the dyn.toString/dyn.valueOf/primitive-method specializations, which assume a primitive receiver. The methods are not generic: a receiver that is neither the kind's primitive nor the prototype object — the wrapper around +0 / false, which is its [[PrimitiveValue]] — is Node's TypeError, so a copied `Number.prototype.toString` called on a plain object throws instead of answering 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>