mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
scr_union_release buffered every union box left alive by a release as a cycle-collector candidate, including boxes whose arm_trace is NULL (scalar arms, and ref arms whose type the compiler proved acyclic, such as TreeNode | null once TreeNode is constructor-only). Such a box's trace visits nothing, so it can never be on a collectable cycle: skip the candidate buffer for it. Deaths check the header's buffered bit inline before calling scr_cyc_on_dead, because typed-ref cache commits swap arm contents between boxes of one union type, so a box can have been buffered under an earlier arm. test_closure.c checks that string- and f64-armed boxes are never buffered, that closure-armed boxes are, and that a closure -> box -> union -> closure cycle is still collected under the RC audit.