mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-13 02:23:10 +08:00
A JavaScript `var` binding hoists to its function, and its slot was created with the checker's type before the initializer lowered. When the initializer was an existing checked-dynamic object (an element of an array built with push, a find result, the object a function returns), the record-typed slot held a converted copy: writes through the binding missed the object that the array or the function's caller still held, and `===` against it was false. `let` and `const` already lowered the initializer first and kept such a value checked-dynamic. A `var` initialized with an existing value now lowers the initializer before creating the slot, and a checked-dynamic value gets a checked-dynamic slot. The same applies to `for (var x of ...)`, to array destructuring with `var`, `let` and `const`, and to file-scope bindings, whose module-entry `undefined` store follows the slot's final type. A literal holding such an object builds checked-dynamic for a `var` as it already did for `let`. TypeScript files and annotated bindings are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>