Skip to content

Fix eval_get in sierra emu #1272

@FrancoGiachetta

Description

@FrancoGiachetta

Currently, in felt252_felt_dict_entry.rs, eval_get is implemented as follows:

pub fn eval_get(
    registry: &ProgramRegistry<CoreType, CoreLibfunc>,
    info: &SignatureAndTypeConcreteLibfunc,
    args: Vec<Value>,
) -> EvalAction {
    let [Value::FeltDict {
        ty,
        mut data,
        mut count,
    }, Value::Felt(key)]: [Value; 2] = args.try_into().unwrap()
    else {
        panic!()
    };
    assert_eq!(info.ty, ty);

    let value = data
        .entry(key)
        .or_insert(Value::default_for_type(registry, &ty))
        .clone();

    count += 1;

    EvalAction::NormalBranch(
        0,
        smallvec![
            Value::FeltDictEntry {
                ty,
                data,
                count,
                key
            },
            value
        ],
    )
}

This is actually wrong with respect to native who, instead of the key, returns a pointer to the entry's value. What this means is that we should be returning this instead:

EvalAction::NormalBranch(
   0,
   smallvec![
       Value::FeltDictEntry {
            ty,
            data,
            count,
            key
        },
        value
    ],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions