(module str_field_in_adt_heap
  (data Boxed
    (doc "Iter hs.4 fixture: single-cell ADT around a Str field. Used to pin the drop discipline for ADTs that carry a heap-Str payload — both the ADT cell and the heap-Str inside it must round-trip through the RC walk.")
    (ctor Box (con Str)))
  (fn main
    (doc "Iter hs.4: pin that `field_drop_call` for `Str` correctly dispatches to `ailang_rc_dec` when the Str payload is heap-Str. Construct `Box(int_to_str(42))`, bind, pattern-match to read the Str, print it. Under --alloc=rc with AILANG_RC_STATS=1: allocs >= 2 (ADT cell + heap-Str slab), allocs == frees, live == 0. drop.rs's Str-arm comment names the codegen-level elision that protects static-Str from this same path; here the Str is heap-allocated so rc_dec is the right (and only) consumer.")
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body (let b (term-ctor Boxed Box (app int_to_str 42)) (match b
      (case (pat-ctor Box s) (seq (do io/print_str s) (do io/print_str "\n"))))))))
