//! > Test enum constructor.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(a: felt252) -> MyEnum {
    immovable(true);
    MyEnum::B({
        ();
        5
    })
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    A: (),
    B: felt252,
    C: Box<((), felt252)>,
}

#[inline(never)]
fn immovable<T>(t: T) -> T {
    t
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: ()) <- struct_construct()
  (v2: core::bool) <- bool::True(v1)
  (v3: core::bool) <- test::immovable::<core::bool>(v2)
  (v4: core::felt252) <- 5
  (v5: test::MyEnum) <- MyEnum::B(v4)
End:
  Return(v5)

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

//! > Multiple variants with the same name.

//! > test_runner_name
test_function_lowering(expect_diagnostics: true)

//! > module_code
enum MyEnum {
    Dup: felt252,
    Dup: felt252,
}

//! > function_code
fn foo(v: MyEnum) -> felt252 {
    match v {
        MyEnum::Dup(x) => x,
    }
}

//! > function_name
foo

//! > semantic_diagnostics
error[E2051]: Redefinition of variant "Dup" on enum "MyEnum".
 --> lib.cairo:3:5
    Dup: felt252,
    ^^^^^^^^^^^^

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::MyEnum
blk0 (root):
Statements:
End:
  Match(match_enum(v0) {
    MyEnum::Dup(v1) => blk1,
  })

blk1:
Statements:
End:
  Return(v1)
