NEWTON
Asked
4 months ago
9
views
0
I am getting the following full error message based on my code:
Can you please explain what is causing this error? I am curious why the struct is failing while 'expanding'
struct simple_struct:
member a : felt
end
func main():
alloc_locals
local test_struct : simple_struct
test_func(test_struct)
return ()
end
func test_func(s : simple_struct):
return()
end
While expanding the reference 'test_struct' in:
test_func(test_struct)
^*********^
Unknown value for memory cell at address 1:2.
local test_struct : simple_struct
^*********^
ㅤ This question was originally posted on Triality
0
The problem is that you have not initialized the properties of the struct and until you do so, you cannot call that struct in a function or attempt to view values in any memory addresses associated with any uninitialized members. To get your code functioning, add the assert test_struct.a = 3
as seen below:
struct simple_struct:
member a : felt
end
func main():
alloc_locals
local test_struct : simple_struct
assert test_struct.a = 3
test_func(test_struct)
return ()
end
func test_func(s : simple_struct):
return()
end
ㅤ This answer was originally posted on Triality
answered
5 months ago
Cairo: Unknown value for memory cell at address
How to fix `bud_ptr`
Cairo: How to reassign Uint256 in a conditional
Cairo 0.10.0 Error: Cannot unpack return value error
how to return struct
Cairo Lang / StarkNet: What are Revoked references? What is alloc_locals?
Cairo Error: Unexpected token Token('LPAR', '('). Expected: identifier.
Is there no way for me to have a struct as a `@storage_var` if it contains an array fo felts inside ?
Can you explain Cairo v0.10 usage functions as expressions?
how I could read a felt* from ap in Cairo lang?
Are you able to nest mappings in Cairo like you can in Solidity?
Cairo: Difference between amount and gas_fee
A plan to get better visibility when a transaction got received but not placed into a block?
What are Event Indexers in Cairo lang? What is a StarkNet indexer?