//! > Test arm pattern destructure for match-enum param.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(e: MyEnum) {
    match e {
        MyEnum::a((_x, (_y, _z))) => {},
        MyEnum::b((_x, _y)) => {},
        MyEnum::c(_x) => {},
        MyEnum::d((_x, _y)) => {},
        MyEnum::e(_x) => {},
        MyEnum::f((_x,)) => {},
        MyEnum::g(_x) => {},
        MyEnum::h(_x) => {},
    }
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    a: (felt252, (felt252, felt252)),
    b: (felt252, (felt252, felt252)),
    c: (felt252, (felt252, felt252)),
    d: (felt252, felt252),
    e: (felt252, felt252),
    f: (felt252,),
    g: (felt252,),
    h: felt252,
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::MyEnum
blk0 (root):
Statements:
End:
  Match(match_enum(v0) {
    MyEnum::a(v1) => blk1,
    MyEnum::b(v2) => blk2,
    MyEnum::c(v3) => blk3,
    MyEnum::d(v4) => blk4,
    MyEnum::e(v5) => blk5,
    MyEnum::f(v6) => blk6,
    MyEnum::g(v7) => blk7,
    MyEnum::h(v8) => blk8,
  })

blk1:
Statements:
End:
  Return()

blk2:
Statements:
End:
  Return()

blk3:
Statements:
End:
  Return()

blk4:
Statements:
End:
  Return()

blk5:
Statements:
End:
  Return()

blk6:
Statements:
End:
  Return()

blk7:
Statements:
End:
  Return()

blk8:
Statements:
End:
  Return()

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

//! > Test arm pattern destructure for match-extern.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(ref a: felt252) {
    match bar(ref a) {
        MyEnum::a((_x, (_y, _z))) => {},
        MyEnum::b((_x, _y)) => {},
        MyEnum::c(_x) => {},
        MyEnum::d((_x, _y)) => {},
        MyEnum::e(_x) => {},
        MyEnum::f((_x,)) => {},
        MyEnum::g(_x) => {},
        MyEnum::h(_x) => {},
    }
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    a: (felt252, (felt252, felt252)),
    b: (felt252, (felt252, felt252)),
    c: (felt252, (felt252, felt252)),
    d: (felt252, felt252),
    e: (felt252, felt252),
    f: (felt252,),
    g: (felt252,),
    h: felt252,
}
extern fn bar(ref a: felt252) -> MyEnum nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::felt252
blk0 (root):
Statements:
End:
  Match(match test::bar(v0) {
    MyEnum::a(v1, v2, v3) => blk1,
    MyEnum::b(v4, v5, v6) => blk2,
    MyEnum::c(v7, v8, v9) => blk3,
    MyEnum::d(v10, v11, v12) => blk4,
    MyEnum::e(v13, v14, v15) => blk5,
    MyEnum::f(v16, v17) => blk6,
    MyEnum::g(v18, v19) => blk7,
    MyEnum::h(v20, v21) => blk8,
  })

blk1:
Statements:
End:
  Return(v1)

blk2:
Statements:
End:
  Return(v4)

blk3:
Statements:
End:
  Return(v7)

blk4:
Statements:
End:
  Return(v10)

blk5:
Statements:
End:
  Return(v13)

blk6:
Statements:
End:
  Return(v16)

blk7:
Statements:
End:
  Return(v18)

blk8:
Statements:
End:
  Return(v20)

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

//! > Test arm pattern destructure for match-enum variable.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo() {
    let y = bar();
    match y {
        MyEnum::a((_x, (_y, _z))) => {},
        MyEnum::b((_x, _y)) => {},
        MyEnum::c(_x) => {},
        MyEnum::d((_x, _y)) => {},
        MyEnum::e(_x) => {},
        MyEnum::f((_x,)) => {},
        MyEnum::g(_x) => {},
        MyEnum::h(_x) => {},
    }
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    a: (felt252, (felt252, felt252)),
    b: (felt252, (felt252, felt252)),
    c: (felt252, (felt252, felt252)),
    d: (felt252, felt252),
    e: (felt252, felt252),
    f: (felt252,),
    g: (felt252,),
    h: felt252,
}
extern fn bar() -> MyEnum nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
End:
  Match(match test::bar() {
    MyEnum::a(v0, v1) => blk1,
    MyEnum::b(v2, v3) => blk2,
    MyEnum::c(v4, v5) => blk3,
    MyEnum::d(v6, v7) => blk4,
    MyEnum::e(v8, v9) => blk5,
    MyEnum::f(v10) => blk6,
    MyEnum::g(v11) => blk7,
    MyEnum::h(v12) => blk8,
  })

blk1:
Statements:
End:
  Return()

blk2:
Statements:
End:
  Return()

blk3:
Statements:
End:
  Return()

blk4:
Statements:
End:
  Return()

blk5:
Statements:
End:
  Return()

blk6:
Statements:
End:
  Return()

blk7:
Statements:
End:
  Return()

blk8:
Statements:
End:
  Return()

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

//! > Test arm pattern destructure for match-extern (with refs and implicits).

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(mut z: felt252) {
    match bar(ref z) {
        MyEnum::a((_x, (_y, _z))) => {},
        MyEnum::b((_x, _y)) => {},
        MyEnum::c(_x) => {},
        MyEnum::d((_x, _y)) => {},
        MyEnum::e(_x) => {},
        MyEnum::f((_x,)) => {},
        MyEnum::g(_x) => {},
        MyEnum::h(_x) => {},
    }
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    a: (felt252, (felt252, felt252)),
    b: (felt252, (felt252, felt252)),
    c: (felt252, (felt252, felt252)),
    d: (felt252, felt252),
    e: (felt252, felt252),
    f: (felt252,),
    g: (felt252,),
    h: felt252,
}
extern fn bar(ref r: felt252) -> MyEnum implicits(RangeCheck) nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::RangeCheck, v1: core::felt252
blk0 (root):
Statements:
End:
  Match(match test::bar(v0, v1) {
    MyEnum::a(v2, v3, v4, v5) => blk1,
    MyEnum::b(v6, v7, v8, v9) => blk2,
    MyEnum::c(v10, v11, v12, v13) => blk3,
    MyEnum::d(v14, v15, v16, v17) => blk4,
    MyEnum::e(v18, v19, v20, v21) => blk5,
    MyEnum::f(v22, v23, v24) => blk6,
    MyEnum::g(v25, v26, v27) => blk7,
    MyEnum::h(v28, v29, v30) => blk8,
  })

blk1:
Statements:
End:
  Return(v2)

blk2:
Statements:
End:
  Return(v6)

blk3:
Statements:
End:
  Return(v10)

blk4:
Statements:
End:
  Return(v14)

blk5:
Statements:
End:
  Return(v18)

blk6:
Statements:
End:
  Return(v22)

blk7:
Statements:
End:
  Return(v25)

blk8:
Statements:
End:
  Return(v28)

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

//! > Test arm pattern destructure for match-enum variable (with refs and implicits).

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(mut z: felt252) {
    let y = bar(ref z);
    match y {
        MyEnum::a((_x, (_y, _z))) => {},
        MyEnum::b((_x, _y)) => {},
        MyEnum::c(_x) => {},
        MyEnum::d((_x, _y)) => {},
        MyEnum::e(_x) => {},
        MyEnum::f((_x,)) => {},
        MyEnum::g(_x) => {},
        MyEnum::h(_x) => {},
    }
}

//! > function_name
foo

//! > module_code
enum MyEnum {
    a: (felt252, (felt252, felt252)),
    b: (felt252, (felt252, felt252)),
    c: (felt252, (felt252, felt252)),
    d: (felt252, felt252),
    e: (felt252, felt252),
    f: (felt252,),
    g: (felt252,),
    h: felt252,
}
extern fn bar(ref r: felt252) -> MyEnum implicits(RangeCheck) nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::RangeCheck, v1: core::felt252
blk0 (root):
Statements:
End:
  Match(match test::bar(v0, v1) {
    MyEnum::a(v2, v3, v4, v5) => blk1,
    MyEnum::b(v6, v7, v8, v9) => blk2,
    MyEnum::c(v10, v11, v12, v13) => blk3,
    MyEnum::d(v14, v15, v16, v17) => blk4,
    MyEnum::e(v18, v19, v20, v21) => blk5,
    MyEnum::f(v22, v23, v24) => blk6,
    MyEnum::g(v25, v26, v27) => blk7,
    MyEnum::h(v28, v29, v30) => blk8,
  })

blk1:
Statements:
End:
  Return(v2)

blk2:
Statements:
End:
  Return(v6)

blk3:
Statements:
End:
  Return(v10)

blk4:
Statements:
End:
  Return(v14)

blk5:
Statements:
End:
  Return(v18)

blk6:
Statements:
End:
  Return(v22)

blk7:
Statements:
End:
  Return(v25)

blk8:
Statements:
End:
  Return(v28)
