cairo
cairo copied to clipboard
bug: accessing member of storage struct named "address" conflicts with storage address
Bug Report
Cairo version: 2.7.0-rc3
Current behavior:
Expected behavior:
Consider the following contract
#[storage]
struct Storage {
owner: Person,
}
#[derive(Drop, Serde, starknet::Store)]
pub struct Person {
address: ContractAddress,
name: felt252,
}
fn get_owner_address(self: @ContractState) -> ContractAddress {
self.owner.address.read()
}
fn get_owner_name(self: @ContractState) -> felt252 {
self.owner.name.read()
}
}
It is not possible to access the addressfield of the owner: Person storage struct, as it conflicts with the storage's var actual address.
Proposal: make address private and access it with a function address().