//! > Test panic.
//! > test_runner_name
test_function_lowering
//! > function
fn foo(ref x: felt252, a: bool) -> felt252 {
x = 7;
let mut data = array![];
data.append(1);
let y = panic(data);
5
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > lowering_diagnostics
//! > lowering_flat
Parameters: v0: core::felt252, v1: core::bool
blk0 (root):
Statements:
(v9: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 1u
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v9, v4)
(v7: core::panics::Panic) <- struct_construct()
(v8: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v7, v10)
(v12: core::panics::PanicResult::<(core::felt252, core::felt252)>) <- PanicResult::Err(v8)
End:
Return(v12)
//! > ==========================================================================
//! > Test call panicable.
//! > test_runner_name
test_function_lowering
//! > function
fn foo(ref x: felt252, ref a: bool) -> felt252 {
if true { x = 7; } else { x = 6; };
bar(ref a)
}
//! > function_name
foo
//! > module_code
fn bar(ref a: bool) -> felt252 {
let mut data = array![];
data.append(1);
let y = panic(data);
5
}
//! > semantic_diagnostics
//! > lowering_diagnostics
//! > lowering_flat
Parameters: v0: core::felt252, v1: core::bool
blk0 (root):
Statements:
(v11: core::panics::PanicResult::<(core::bool, core::felt252)>) <- test::bar(v1)
End:
Match(match_enum(v11) {
PanicResult::Ok(v12) => blk1,
PanicResult::Err(v15) => blk2,
})
blk1:
Statements:
(v5: core::felt252) <- 7u
(v13: core::bool, v14: core::felt252) <- struct_destructure(v12)
(v16: (core::felt252, core::bool, core::felt252)) <- struct_construct(v5, v13, v14)
(v17: core::panics::PanicResult::<(core::felt252, core::bool, core::felt252)>) <- PanicResult::Ok(v16)
End:
Return(v17)
blk2:
Statements:
(v18: core::panics::PanicResult::<(core::felt252, core::bool, core::felt252)>) <- PanicResult::Err(v15)
End:
Return(v18)