NEWTON
Asked
9 months ago
5
views
0
What is the cause of this issue and how do you solve it?
ㅤ This question was originally posted on Triality
0
If you run the following code, you will get the following error : Expected 'testFuncB' to be a struct. Found: 'function'.
return (res=testFuncB(x))
^**********^
func main():
testFuncA()
return ()
end
#This function calls another function to add one
func testFuncA() -> (res : felt):
let x = 1
return (res=testFuncB(x))
end
#This function adds one to the input
func testFuncB(input : felt) -> (res : felt):
return (input+1)
end
If you unpack the call to testFuncB and set the variable in it's own line, you will solve the problem.
func main():
testFuncA()
return ()
end
#This function calls another function to add one
func testFuncA() -> (res : felt):
let x = 1
**let (res) = testFuncB(x)**
return (res=res)
end
#This function adds one to the input
func testFuncB(input : felt) -> (res : felt):
return (input+1)
end
ㅤ This answer was originally posted on Triality
answered
8 months ago
0
Looking at the documentation, there seems to be two possibilities
ㅤ This answer was originally posted on Triality
answered
8 months ago
Cairo: Getting function selector
Cairo: How do write a log function in Cairo
Cairo: How do I initialize an array in cairo
Cairo Passing Functions
Cairo: How to return true from a function?
Cairo: Expected '__main__.Id' to be a struct. Found: 'future'
Cairo: are builtins always needed to be expressed in function signature?
Is it possible to transpile contracts that use openzeppelin libraries?
Does Kakarot zkEVM have a token?
What should I use to execute abi.encodePacked from solidity in starknet?
Is there a way to accelerate pytest for cairo contract?
Has anyone had `get_caller_address` problems in devnet ?
What hashing functions are available in Cairo? How are they secure?
Equivalent to Solidity's keccak256(abi.encodePacked())?