Created
August 30, 2022 20:46
-
-
Save rlkelly/272bcba76188efdeaf25aa23d383a8d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%builtins output | |
from starkware.cairo.common.alloc import alloc | |
from starkware.cairo.common.invoke import invoke | |
from starkware.cairo.common.registers import get_label_location | |
struct A: | |
member a: felt | |
member b: felt | |
end | |
func get_value(a: A, b: A) -> (f: felt): | |
let res = a.a + b.b | |
return (res) | |
end | |
func main{output_ptr : felt*}(): | |
tempvar a = new A(a=1, b=2) | |
tempvar b = new A(a=3, b=4) | |
let (ptr_arr: felt*) = alloc() | |
assert ptr_arr[0] = cast(a, felt) | |
assert ptr_arr[1] = cast(b, felt) | |
let (func_pc) = get_label_location(get_value) | |
invoke(func_pc, 2, ptr_arr) | |
return () | |
end | |
# Error: code:15:13: While expanding the reference 'res' in: | |
# return (res) | |
# ^ | |
# code:14:13: Error at pc=0:32: | |
# Cannot add two relocatable values: 1:41 + 1:11. | |
# let z = a.a + b.b | |
# ^*******^ | |
# Cairo traceback (most recent call last): | |
# code:26:5: (pc=0:61) | |
# invoke(func_pc, 2, ptr_arr) | |
# ^*************************^ | |
# /var/task/starkware/cairo/common/invoke.cairo:6:5: (pc=0:13) | |
# call abs func_ptr | |
# ^***************^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment