Open zzjas opened 2 months ago
Similar case:
//# publish
module 0xCAFE::FuzzStore {
struct S has drop, copy, store, key {
x: u8
}
fun init(s: signer) {
move_to<S>(&s, S { x: 0 });
}
public fun inc() acquires S {
let s = borrow_global_mut<S>(@0xBEEF);
s.x = s.x + 1;
}
}
//# run 0xCAFE::FuzzStore::init --signers 0xBEEF
//# publish
module 0xCAFE::Module0 {
use 0xCAFE::FuzzStore::inc;
public fun f1(): u8 {
f2() ^ (return 123u8);
0
}
public fun f2(): u8 {
inc();
0
}
}
//# run 0xCAFE::Module0::f1
//# view --address 0xBEEF --resource 0xCAFE::FuzzStore::S
Transactional output:
...
= task 4 'view'. lines 34-34:
= copy drop store key 0xcafe::FuzzStore::S {
- x: 0u8
+ x: 1u8
= }
Compiling with aptos move compile --compiler-version=2 --language-version=1
didn't give any warning.
I had to use a separate module for this one because V1 will optimize away the left operand -- making the compiler fail with extraneous acquires error.
🐛 Bug
Running this as transactional test will give:
A warning about the difference between V1 and V2 semantics is expected.