cairo-lang icon indicating copy to clipboard operation
cairo-lang copied to clipboard

with_attr syntax error not detected

Open milancermak opened this issue 3 years ago • 0 comments

This contract compiles without any issue (with 0.10.1 toolchain):

%lang starknet

from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.cairo.common.math import assert_nn

@storage_var
func balance() -> (amount: felt) {
}

@external
func deposit{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(amount: felt) {
    with_attr errro_message("incorrect amount") {
        assert_nn(amount);
    }

    balance.write(amount);

    return ();
}

Notice though there's an error in the spelling of with_attr errro_message - it should be error_message. This is only detected at run time - a transaction executing this function fails. IMHO this should not compile at all.

milancermak avatar Oct 25 '22 15:10 milancermak