-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: [loop] Says moved when it shouldn't #2816
Comments
I am getting a similar issue with the following code fn balance_of_batch(mut accounts: Array<ContractAddress>, mut ids: Array<u256>) -> Array<u256> {
let mut balances: Array<u256> = ArrayTrait::new();
loop {
let account = accounts.pop_front();
let id = ids.pop_front();
if (account.is_some() & id.is_some()) {
balances.append(ERC1155::balance_of(
account.unwrap(),
id.unwrap()
));
} else if (account.is_none() & id.is_none()) {
break balances;
} else {
panic_with_felt252('ERC1155 invalid array length');
};
}
} is causing
|
The issue is that the logic for checking which variables member paths (i.e. a.b.c), does not include snapshot tracking. Guidance: At ref.rs, there is a logic to correctly treat member paths as variables inside code. For example, when assigning (a.b=5) or passing them as ref parameters (foo(ref a.b)). This is done with the break_into_value() and assemble_value() value function. The first deconstructs as needed, the other constructs as needed. Goals:
Tasks:
This issue is probably large and non-trivial |
Looking forward to this feature! |
Bug Report
Cairo version:
Tested at alpha.7
Current behavior:
When doing
It doesn't work because self is moved and doesn't allow such behaviour.
Looks like loop doesn't understand it only needs to get @self instead of self.
The text was updated successfully, but these errors were encountered: