NEWTON
Asked
6 months ago
2
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
6 months ago
0
Looking at the documentation, there seems to be two possibilities
ㅤ This answer was originally posted on Triality
answered
6 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?
What libraries are secure to use in Cairo?
How to verify Empiric’s Data Entries Using Events?
How to transpile multiple contracts at once using warp?
How do I run a Pathfinder node?
An error “AssertionError: Sender must be passed explicitly when making a direct declaration using —no_wallet.” using the new nile?
My ABIs will be same right? In UI I am assuming I wont have to make any changes
ApeWorX: How do I call an account while trying to test a function?