//# publish module 0x1.A { struct Coin has store { u: u64 } public new(): Self.Coin { label b0: return Coin { u: 1 }; } public join(c1: Self.Coin, c2: Self.Coin): Self.Coin { let u1: u64; let u2: u64; label b0: Coin { u: u1 } = move(c1); Coin { u: u2 } = move(c2); return Coin { u: move(u1) + move(u2) }; } public split(c1: Self.Coin, amt: u64): Self.Coin * Self.Coin { let u1: u64; let u2: u64; label b0: Coin { u1 } = move(c1); assert(copy(u1) >= copy(amt), 42); u1 = move(u1) - copy(amt); u2 = copy(amt); return Coin { u: move(u1) }, Coin { u: move(u2) }; } } //# publish module 0x1.Tester { import 0x1.A; struct Pair has key { x: A.Coin, y: A.Coin } no1(addr1: address, addr2: address): bool acquires Pair { let p1: &mut Self.Pair; let p2: &mut Self.Pair; label b0: p1 = borrow_global_mut(move(addr1)); // Pair still acquired mutably p2 = borrow_global_mut(move(addr2)); return move(p1) == move(p2); } } //# publish module 0x1.Tester { import 0x1.A; struct Pair has key { x: A.Coin, y: A.Coin } no2(addr1: address, addr2: address): bool acquires Pair { let p1: &Self.Pair; let p2: &Self.Pair; label b0: p1 = freeze(borrow_global_mut(move(addr1))); // Pair still acquired mutably p2 = freeze(borrow_global_mut(move(addr2))); return move(p1) == move(p2); } } //# publish module 0x1.Tester { import 0x1.A; struct Pair has key { x: A.Coin, y: A.Coin } no3(addr1: address, addr2: address): bool acquires Pair { let p1: &mut Self.Pair; let p2: &mut Self.Pair; let c1: &A.Coin; let c2: &A.Coin; label b0: p1 = borrow_global_mut(move(addr1)); c1 = &move(p1).Pair::x; // Pair still acquired mutably p2 = borrow_global_mut(move(addr2)); c2 = &move(p2).Pair::x; return move(c1) == move(c2); } }