; Iter 18g.tidy.fu2 RED-test fixture 2/3: dynamic-tag partial-drop ; carve-out at outer-arm-close pattern-binder dec ; (Iter A / match_lower.rs:839). ; ; Shape: ; - `Pair` carries two `Cell` fields; `Cell` carries two `Wrap` ; fields. (Same types as fixture 1.) ; - `use_first` takes `(own Pair)` and the OUTER match binds both ; slots: `MkPair a b`. ; - The arm body INNER-matches `a` as `MkCell w1 _` — slot 0 of ; a is bound, slot 1 is wildcarded. ; - Inner arm-close drops `w1` properly via `drop__Wrap`. ; Inner match adds slot 0 to `moved_slots[a]`. ; - Outer arm-close drops `a` and `b`. `a` has `moves={0}` ; (non-empty) and `consume_count==0` (only Borrow use as ; scrutinee of inner match) → Iter A's dynamic-tag carve-out ; fires: shallow `ailang_rc_dec(a)`. a's outer Cell is freed, ; but slot 1 (the unbound MkWrap(2) cell) leaks. ; - `b` has `moves={}` and `consume_count==0` → routes through ; `drop__Cell(b)` which cascades through both Wraps. No ; leak from b. ; - At fn return, `p`'s `moves={0,1}` (both slots bound) → Iter ; B carve-out fires too, but with all slots moved, the shallow ; dec is correct (no additional leak from p). ; ; Pre-fix: live = 1 (the unbound MkWrap(2) cell in slot 1 of a). ; Post-fix: live = 0. (module rc_match_arm_partial_drop_leak (data Wrap (ctor MkWrap (con Int))) (data Cell (ctor MkCell (con Wrap) (con Wrap))) (data Pair (ctor MkPair (con Cell) (con Cell))) (fn build_pair (type (fn-type (params (con Int)) (ret (own (con Pair))))) (params n) (body (term-ctor Pair MkPair (term-ctor Cell MkCell (term-ctor Wrap MkWrap n) (term-ctor Wrap MkWrap 2)) (term-ctor Cell MkCell (term-ctor Wrap MkWrap 3) (term-ctor Wrap MkWrap 4))))) (fn use_first (type (fn-type (params (own (con Pair))) (ret (con Int)))) (params p) (body (match p (case (pat-ctor MkPair a b) (match a (case (pat-ctor MkCell w1 _) 1)))))) (fn main (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (do io/print_int (app use_first (app build_pair 1))))))