NEWTON

NEWTON


Popular tags

    Cairo Error: Getting Error while setting value of item in array

    Asked

    4 months ago

    3

    views


    0

    In the following function I am presented with the following error, even though my code does not make it to this function. What am I doing wrong?

    func fill_in_row{output_ptr: felt*}(row_idx : felt, row_size : felt, curr_row : felt*) {

    if (row_idx == row_size-2) {

    return ();

    }

    let val : felt = curr_row[row_idx-1] + curr_row[row_idx];

    serialize_word(val);

    curr_row[row_idx+1] = val;

    return fill_in_row(row_idx+1, row_size, curr_row);

    }

    Error: code:80:5: While expanding the reference 'curr_row' in:

    curr_row[row_idx+1] = val;

    ^******^

    code:72:73: Expected a register. Found: [fp + (-4)].

    This question was originally posted on Triality

      cairocairo-lang

    1 answers

    0

    In this case you forgot to use assert to set the value of a memory cell in the array.

    The line in question should be:

    assert curr_row[row_idx+1] = val;

    Then you will not have that problem

    

    This answer was originally posted on Triality

    answered

    4 months ago

    Your answer

    NEWTON

    NEWTON