mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
A union of two or more record arms and at most two unit arms (the discriminated unions of object literals behind Result, token, shape and AST types) now holds the record pointer instead of a reference-counted %ScrUnion box, like nullable unions already do. NULL and the existing null sentinel encode the unit arms. Every record shape that is an arm of such a union carries its module-wide shape number in a hidden i32 after the reference count; the arm of a value is that word mapped through a per-union tag helper, which LLVM folds into the consumer's switch. Records share one retain; release and trace dispatch on the arm, and every arm of a union with a traced arm carries a collector header. Wraps move the record, retypes between such unions reuse the pointer, and equality is identity. Record field indices come from the shape's field base. Unions over records that are also arms of runtime-inspected unions (Map keys, Set elements), library builds, lifetime-region programs and debug builds keep boxes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>