Skip to content

Instantly share code, notes, and snippets.

@rlkelly
Created August 25, 2022 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlkelly/6cc8f4cce06762c3153fc7e3acaf9429 to your computer and use it in GitHub Desktop.
Save rlkelly/6cc8f4cce06762c3153fc7e3acaf9429 to your computer and use it in GitHub Desktop.
%lang starknet
from starkware.cairo.common.alloc import alloc
struct Foo:
member val: felt
end
func make_foo(value: felt) -> (foo: Foo):
let foo = Foo(
val=value,
)
return (foo)
end
func make_foo_array() -> (entry: Foo*):
let (struct_array : Foo*) = alloc()
let foo0 = make_foo(0)
assert struct_array[0] = foo0
return (struct_array)
end
@external
func test_make_foo{syscall_ptr : felt*, range_check_ptr}():
let (foo_array) = make_foo_array()
return ()
end
# File "starkware/cairo/lang/compiler/preprocessor/preprocessor.py", line 1223, in visit_CodeElementCompoundAssertEq
# starkware.cairo.lang.compiler.preprocessor.preprocessor_error.PreprocessorError: contracts/tests/test_foo.cairo:22:5: Cannot compare '__main__.Foo' and '(foo : __main__.Foo)'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment