Closed Acaccia closed 4 months ago
The evaluation order of tuples in a compiled clarity code evaluates the tuple fields in the lexicographical order of the keys, while it is evaluated in order of definition in the interpreter.
Here is an example:
#[test] fn tuple_check_evaluation_order() { let snippet = r#" (define-data-var foo int 1) { b: (var-set foo 2), a: (var-get foo) } "#; let expected = Value::from( TupleData::from_data(vec![ (ClarityName::from("b"), Value::Bool(true)), (ClarityName::from("a"), Value::Int(2)), ]) .unwrap(), ); crosscheck(snippet, Ok(Some(expected))); }
This snippet has two different answers:
{a: 2, b: true}
{a: 1, b: true}
The evaluation order of tuples in a compiled clarity code evaluates the tuple fields in the lexicographical order of the keys, while it is evaluated in order of definition in the interpreter.
Here is an example:
This snippet has two different answers:
{a: 2, b: true}
{a: 1, b: true}