Closed rahxephon89 closed 3 weeks ago
Another related example:
//# publish
module 0xCAFE::Module0 {
use std::vector;
public fun function1() : u8 {
let x: vector<u8> = vector[123u8];
let y = vector::borrow<u8>(&x, 0);
vector::push_back<u8>(&mut x, *y);
vector::pop_back<u8>(&mut x)
}
}
//# run 0xCAFE::Module0::function1
V2 gives:
error: cannot mutably borrow since immutable references exist
┌─ TEMPFILE:7:31
│
6 │ let y = vector::borrow<u8>(&x, 0);
│ -------------------------
│ │ │
│ │ previous local borrow
│ used by call result
7 │ vector::push_back<u8>(&mut x, *y);
│ ^^^^^^ -- requirement enforced here
│ │
│ mutable borrow attempted here
fixed by #14276
🐛 Bug
When compiling the following program using V2:
Following error is generated: