You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package fun deposit(account: address, coin: Coin) acquires Account {
// What I have to write
//(&mut Account[account].balance).merge(coin)
// What I wish to write but got error message
Account[account].balance.merge(coin)
}
where fun merge(self: &mut Coin, Coin)
The produced error message is
error: cannot mutably borrow from an immutable ref
┌─ /Users/wrwg/move-demo/sources/account.move:20:9
│
20 │ Account[account].balance.merge(coin)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It appears that the decision to imm-ref the index Account[account] is taken before its known that it needs to be mutable. This might be a difficult problem to fix, but its a bit of annoying.
The text was updated successfully, but these errors were encountered:
Consider code as below:
The produced error message is
It appears that the decision to imm-ref the index
Account[account]
is taken before its known that it needs to be mutable. This might be a difficult problem to fix, but its a bit of annoying.The text was updated successfully, but these errors were encountered: