cairo-lang-semantic 2.21.0

Cairo semantic model.
Documentation
//! > Test free function param redefinition.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > cairo_code
fn foo(a: bool, a: felt252) {}

//! > expected_diagnostics
error[E2054]: Redefinition of parameter name "a" in function "foo".
 --> lib.cairo:1:17
fn foo(a: bool, a: felt252) {}
                ^^^^^^^^^^

//! > ==========================================================================

//! > Test valid free function with implicit params.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: false)

//! > cairo_code
fn foo(a: bool) implicits(felt252, bool) {}

//! > expected_diagnostics

//! > ==========================================================================

//! > Test uninferred const generic param.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > cairo_code
fn bar<const n: u16>(a: bool) {}
fn foo(a: bool) {
    bar(a)
}

//! > expected_diagnostics
error[E2310]: Failed to infer constant.
 --> lib.cairo:3:5
    bar(a)
    ^^^

//! > ==========================================================================

//! > Test no ICE when an item-level macro call names an enum variant whose type comes from a generic free function with a trait bound.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > cairo_code
fn g<T, +Drop<T>>(x: T) {}
enum E {
    A: g::<felt252>::Coupon,
}
E::A!(());

//! > expected_diagnostics
error[E2028]: Cycle detected while resolving generic param. Try specifying the generic impl parameter explicitly to break the cycle.
 --> lib.cairo:1:9
fn g<T, +Drop<T>>(x: T) {}
        ^^^^^^^^

error[E2156]: Inline macro `E::A` not found.
 --> lib.cairo:5:1
E::A!(());
^^^^^^^^^^