cairo-lang-semantic 2.18.0

Cairo semantic model.
Documentation
//! > Test basic return.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: false)

//! > function_code
fn foo() -> felt252 {
    return 1 + 2;
}

//! > function_name
foo

//! > expected_diagnostics

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

//! > Test unreachable tail statement.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: false)

//! > function_code
fn foo() -> felt252 {
    return 1 + 2;
    35
}

//! > function_name
foo

//! > expected_diagnostics

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

//! > Test unreachable internal return.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: false)

//! > function_code
fn foo(x: felt252) -> felt252 {
    match x {
        0 => { return 5; },
        1 => { return 6; },
        2 => { return 9; },
    }
}

//! > function_name
foo

//! > expected_diagnostics

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

//! > Test type mismatch in return.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > function_code
fn foo() -> felt252 {}

//! > function_name
foo

//! > expected_diagnostics
error[E2042]: Unexpected return type. Expected: "core::felt252", found: "()".
 --> lib.cairo:1:13
fn foo() -> felt252 {}
            ^^^^^^^