mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-12 02:13:04 +08:00
zod 4 builds every schema through `$constructor`, a factory of JavaScript
patterns the dynamic tier refused or answered wrongly. Each is fixed
generally:
- `"key" in BuiltinCtor` (`"captureStackTrace" in Error`) folds to Node's
answer from a table of the builtin constructor globals' keys.
- A class whose heritage evaluates to Object or Error at runtime
(`class D extends (params?.Parent ?? Object)`): Object means no
heritage; Error links Error.prototype and super() installs message,
cause and stack.
- `Object.defineProperty` on a class value boxes to its constructor, and
a JavaScript class targeted by defineProperty gets a live static table.
- A Symbol.hasInstance defined on a function's own table answers
untyped `instanceof`; an error constructor held as a value answers by
error kind.
- A builtin error constructor stored in a slot of its class value type
(`{ Parent: Error }`) is the class value, not a checked cast that fails.
- A function hoisted above a local class it references captures the
class binding as a TDZ box the class statement initializes.
- Names a program stores on the global object read back from it instead
of folding to undefined.
- A module namespace whose exports never change converts to an untyped
object (`{ ...ns }`).
- An untyped call of a String-only method name (`x.trim()`) dispatches on
the receiver's runtime kind, so objects defining that member work.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>