Open gaetbout opened 10 months ago
Cairo version:
scarb 2.3.1 (0c8def3aa 2023-10-31) cairo: 2.3.1 (https://crates.io/crates/cairo-lang-compiler/2.3.1) sierra: 1.3.0
Current behavior:
When doing this component:
#[starknet::component] mod lama_contract { #[derive(PartialEq, Copy, Drop, Serde, starknet::Store)] struct Lama { lama: u128 } #[storage] struct Storage { my_lama_map: LegacyMap::<(felt252, felt252), Lama>, } #[event] #[derive(Drop, starknet::Event)] enum Event {} #[generate_trait] impl Internal<TContractState, +HasComponent<TContractState>> of InternalTrait<TContractState> { fn set_model(self: @ComponentState<TContractState>) { let my_lama = self.my_lama_map.read((12, 12)); assert(my_lama.lama == 0, 'lama-error'); } } }
and running scarb build I run into:
scarb build
error: Type annotations needed. Failed to infer ?2 --> /REDACTED/src/lama.cairo:22:28 assert(my_lama.lama == 0, 'lama-error'); ^**^
However if I change let my_lama = self.my_lama_map.read((12, 12)); to let my_lama: Lama = self.my_lama_map.read((12, 12)); It works.
let my_lama = self.my_lama_map.read((12, 12));
let my_lama: Lama = self.my_lama_map.read((12, 12));
This works outside of a component...
I believe it is related to ComponentMemberState
ComponentMemberState
Expected behaviour The type should be automatically infered
Encountered this issue again in another project
Bug Report
Cairo version:
scarb 2.3.1 (0c8def3aa 2023-10-31) cairo: 2.3.1 (https://crates.io/crates/cairo-lang-compiler/2.3.1) sierra: 1.3.0
Current behavior:
When doing this component:
and running
scarb build
I run into:However if I change
let my_lama = self.my_lama_map.read((12, 12));
tolet my_lama: Lama = self.my_lama_map.read((12, 12));
It works.This works outside of a component...
I believe it is related to
ComponentMemberState
Expected behaviour The type should be automatically infered