type RefBox {
    item: ref<i32>,
}

type Source {
    items: [1]ref<i32>,
    other: ref<i32>,
    fn replaceOther(self: mutref<Self>, next: ref<i32>) -> RefBox {
        self.other = next
        return RefBox { item: self.items[0] }
    }
}

pub fn main() -> Void {
    var x: i32 = 1
    let y: i32 = 2
    let z: i32 = 3
    var source: Source = Source { items: [&x], other: &z }
    let copy: RefBox = source.replaceOther(&y)
    source.items = [&y]
    x = 4
}
