E0049: Linear Method Call Violation
Only one method call is allowed on a narrowed ABI variable per if ... is block. Calling a second method is a hard error because ABI method calls can change the Utxo's state, potentially invalidating the ABI type.
Example (error)
abi MyAbi {
fn transfer(amount: i64) -> bool;
fn balance() -> i64;
}
fn test(x: Utxo) {
if x is MyAbi {
x.transfer(100); // OK: first method call
x.balance(); // Error: second method call on narrowed variable
}
}
Fix
Use separate if ... is blocks for each method call:
fn test(x: Utxo) {
if x is MyAbi {
x.transfer(100);
}
if x is MyAbi {
x.balance();
}
}