module 0x42::TestMonomorphization { use std::signer; use std::bcs; use std::event; use std::vector; struct R has key { x: T, y: T } public fun pack_R(): R { R{x: 1, y: 2} } spec pack_R { ensures result == spec_pack_R(); } spec fun spec_pack_R(): R { R{x: 1u64, y: 2}} public fun create_R(account: &signer) { move_to>(account, R{x:1, y:2} ); } spec create_R { aborts_if exists>(signer::address_of(account)); ensures exists>(signer::address_of(account)); } public fun mutate_R(addr: address) acquires R { borrow_global_mut>(addr).y = false; } spec mutate_R { ensures global>(addr) == update_field(old(global>(addr)), y, false); } public fun create_R_generic(account: &signer, x: T, y: T) { move_to>(account, R{x, y}); } spec create_R_generic { aborts_if exists>(signer::address_of(account)); ensures exists>(signer::address_of(account)); } public fun use_vec(_x: vector) { } public fun use_bcs(x: &T): (vector, vector) { (bcs::to_bytes(x), bcs::to_bytes(&@0x2)) } spec use_bcs { ensures result_1 == bcs::serialize(x); ensures result_2 == bcs::serialize(@0x2); } struct E has copy, drop, store { msg: u64 } public fun use_event(handle: &mut event::EventHandle) { event::emit_event(handle, E{msg: 0}); } spec use_event { emits E{msg: 0} to handle; } // The following set of functions exercise different style of vector instantiations each with an error which // should print the vector. Running outside of the test environment (without value redaction) allow to manually // inspect printing. public fun vec_int(x: vector): vector { vector::push_back(&mut x, 1); x } spec vec_int { ensures result[0] != 1; } public fun vec_addr(x: vector
): vector
{ vector::push_back(&mut x, @0x1); x } spec vec_addr { ensures result[0] != @0x1; } public fun vec_bool(x: vector): vector { vector::push_back(&mut x, true); x } spec vec_bool { ensures result[0] != true; } public fun vec_struct_int(x: vector>): vector> { vector::push_back(&mut x, R{x: 1u64, y: 1}); x } spec vec_struct_int { ensures result[0].x != 1; } public fun vec_struct_addr(x: vector>): vector> { vector::push_back(&mut x, R{x: @0x1, y: @0x2}); x } spec vec_struct_addr { ensures result[0].x != @0x1; } public fun vec_vec(x: vector>): vector> { vector::push_back(&mut x, vector::empty()); x } spec vec_vec { ensures len(result[0]) != 0; } }