//# publish module 0x42.Tester { struct T has drop {v: u64} public new(v: u64): Self.T { label b0: return T{v: move(v)}; } public replace(t: &mut Self.T) { let t2: &mut Self.T; let t_v: &mut u64; let new_t: Self.T; label b0: t2 = copy(t); t_v = &mut copy(t2).T::v; *move(t_v) = 10000; new_t = Self.new(1); *move(t2) = move(new_t); _ = move(t); return; } public value(this: &mut Self.T): u64 { let ref_v: &u64; label b0: ref_v = &move(this).T::v; return *move(ref_v); } } //# run import 0x42.Tester; main() { let t: Tester.T; let ref_t: &mut Tester.T; let v_from_ref: u64; let tt: &mut Tester.T; let v_from_t: u64; label b0: t = Tester.new(0); ref_t = &mut t; // valid as this is the only reference to t Tester.replace(copy(ref_t)); v_from_ref = Tester.value(move(ref_t)); tt = &mut t; v_from_t = Tester.value(move(tt)); assert(copy(v_from_ref) == 1, 42); assert(copy(v_from_t) == 1, 42); return; }