mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Recursive declarations own distinct shape ids even when their layouts
coincide, while the structural interning key names only the first of
them. A refinement intersection such as `Expr & { kind: "mul" }` (which
the checker reduces to `Mul & { kind: "mul" }`) was interned by
structure, so it could resolve to a lookalike declaration's shape: a
different arm of the union being narrowed. Checked assertions and type
guards then threw the stranded-arm TypeError on valid values, and
flow-narrowed assertions copied the record into the lookalike layout,
severing identity.
The natively compiled compiler hit this rebuilding itself once the
direct array-callback lowering added `read.cond as IrExpr & { kind:
"bin" }`: that type resolved to the `logical` arm's shape, so the native
bootstrap jobs failed with SC3004. main has since rewritten that
lowering to narrow by `kind` checks (a52126b8), which keeps the
bootstrap green but leaves the type-mapper bug in place: corpus 4143
still prints only its first line natively on main in both lanes.
An intersection whose mapped layout equals one of its own constituents'
layouts now keeps that constituent's shape.