NEWTON

NEWTON


Popular tags

    Cairo Error: 'While expanding the reference 'test_struct' in'

    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

      cairocairo-lang

    1 answers

    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

    Your answer

    NEWTON

    NEWTON