cairo-lang-semantic 2.18.0

Cairo semantic model.
Documentation
//! > Test const initialization

//! > test_runner_name
test_expr_semantics(expect_diagnostics: false)

//! > function_body
const X: u8 = 2;
const Y: u8 = X;

//! > expr_code
X + Y

//! > expected_semantics
FunctionCall(
    ExprFunctionCall {
        function: core::integer::U8Add::add,
        args: [
            Value(
                Constant(
                    ExprConstant {
                        const_value_id: 2,
                        ty: core::integer::u8,
                    },
                ),
            ),
            Value(
                Constant(
                    ExprConstant {
                        const_value_id: 2,
                        ty: core::integer::u8,
                    },
                ),
            ),
        ],
        coupon_arg: None,
        ty: core::integer::u8,
    },
)

//! > expected_diagnostics

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

//! > Test const assignment from module

//! > test_runner_name
test_expr_semantics(expect_diagnostics: false)

//! > module_code
const X: u8 = 2;

//! > function_body
const Y: u8 = X;

//! > expr_code
Y

//! > expected_semantics
Constant(
    ExprConstant {
        const_value_id: 2,
        ty: core::integer::u8,
    },
)

//! > expected_diagnostics

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

//! > Test const shadowing

//! > test_runner_name
test_expr_semantics(expect_diagnostics: false)

//! > module_code
const X: u8 = 2;

//! > function_body
const X: u8 = 4;
const Y: u8 = X;

//! > expr_code
Y

//! > expected_semantics
Constant(
    ExprConstant {
        const_value_id: 4,
        ty: core::integer::u8,
    },
)

//! > expected_diagnostics

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

//! > Test unused const

//! > test_runner_name
test_expr_semantics(expect_diagnostics: true)

//! > function_body
const X: u8 = 4;
const Y: u8 = 4;

//! > expr_code
Y

//! > expected_semantics
Constant(
    ExprConstant {
        const_value_id: 4,
        ty: core::integer::u8,
    },
)

//! > expected_diagnostics
warning[E2070]: Unused constant. Consider ignoring by prefixing with `_`.
 --> lib.cairo:1:24
fn test_func() { const X: u8 = 4;
                       ^

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

//! > Test const behavior

//! > test_runner_name
test_expr_semantics(expect_diagnostics: false)

//! > module_code
const X: u8 = 2;

//! > function_body
const Y: u8 = X;
const X: u8 = 4;

//! > expr_code
Y + X

//! > expected_semantics
FunctionCall(
    ExprFunctionCall {
        function: core::integer::U8Add::add,
        args: [
            Value(
                Constant(
                    ExprConstant {
                        const_value_id: 2,
                        ty: core::integer::u8,
                    },
                ),
            ),
            Value(
                Constant(
                    ExprConstant {
                        const_value_id: 4,
                        ty: core::integer::u8,
                    },
                ),
            ),
        ],
        coupon_arg: None,
        ty: core::integer::u8,
    },
)

//! > expected_diagnostics