mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +08:00
A module `let` declared without an initializer whose type uses its null pointer as the TDZ sentinel (a function, for example) is initialized when its declaration runs, while its slot is still empty. markUninitializedWrites marked the assignment statements that run after the declaration as initializing, but not assignments in expression position. Those ran the pointer check and threw "ReferenceError: Cannot access 'g' before initialization" where Node stores the value, so the deferred-resolver pattern `let resolve!: ...; new Promise((r) => (resolve = r))` failed, as did `(h) => (g = h)` and `const r = (g = h)`. An assignment expression to such a binding now becomes an initializing `assign` whose value a temp holds and yields. Writes that can run before the declaration keep the flag check, so they still throw Node's ReferenceError.