//! > Test panic.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(ref x: felt252, a: bool) -> felt252 {
    x = 7;
    let mut data = array![];
    data.append(1);
    panic(data)
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::felt252, v1: core::bool
blk0 (root):
Statements:
  (v2: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
  (v3: core::felt252) <- 1
  (v4: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v2, v3)
  (v5: core::panics::Panic) <- struct_construct()
  (v6: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v5, v4)
  (v7: core::panics::PanicResult::<(core::felt252, core::felt252)>) <- PanicResult::Err(v6)
End:
  Return(v7)

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

//! > Test call panicable.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(ref x: felt252, ref a: bool) -> felt252 {
    if true {
        x = 7;
    } else {
        x = 6;
    }
    bar(ref a)
}

//! > function_name
foo

//! > module_code
#[inline(never)]
fn bar(ref a: bool) -> felt252 {
    let mut data = array![];
    data.append(1);
    panic(data)
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::felt252, v1: core::bool
blk0 (root):
Statements:
  (v2: core::panics::PanicResult::<(core::bool, core::felt252)>) <- test::bar(v1)
End:
  Match(match_enum(v2) {
    PanicResult::Ok(v3) => blk1,
    PanicResult::Err(v4) => blk2,
  })

blk1:
Statements:
  (v5: core::felt252) <- 7
  (v6: core::bool, v7: core::felt252) <- struct_destructure(v3)
  (v8: (core::felt252, core::bool, core::felt252)) <- struct_construct(v5, v6, v7)
  (v9: core::panics::PanicResult::<(core::felt252, core::bool, core::felt252)>) <- PanicResult::Ok(v8)
End:
  Return(v9)

blk2:
Statements:
  (v10: core::panics::PanicResult::<(core::felt252, core::bool, core::felt252)>) <- PanicResult::Err(v4)
End:
  Return(v10)
