stacks-network / clarity-wasm

`clar2wasm` is a compiler for generating WebAssembly from Clarity.
GNU General Public License v3.0
12 stars 9 forks source link

The type workaround provokes errors in `append` #412

Closed Acaccia closed 1 month ago

Acaccia commented 1 month ago

The type workaround for the function append sets the same type for the argument as the type of the result. This leads to undefined behavior since we then use a memory.copy with the size of the result instead of the size of the argument.

Here is a failing example with the append function:

#[test]
fn double_append() {
    let snippet = "(append (append (list 1) 2) 3)";

    let expected = Value::Sequence(SequenceData::List(ListData {
        data: vec![
            Value::Int(1),
            Value::Int(2),
            Value::Int(3),
        ],
        type_signature: ListTypeData::new_list(TypeSignature::IntType, 3).unwrap(),
    }));

    crosscheck(snippet, Ok(Some(expected)))
}