//! > Test const folding simple scenario.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(a: felt252) -> felt252 {
let b = a - 0;
b - 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > lowering_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::felt252) <- 0
(v2: core::felt252) <- core::felt252_sub(v0, v1)
(v3: core::felt252) <- 0
(v4: core::felt252) <- core::felt252_sub(v2, v3)
End:
Return(v4)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::felt252) <- 0
(v2: core::felt252) <- core::felt252_sub(v0, v1)
(v3: core::felt252) <- 0
(v4: core::felt252) <- core::felt252_sub(v0, v3)
End:
Return(v0)
//! > ==========================================================================
//! > Basic box const folding.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> Box<felt252> {
BoxTrait::new(0)
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::box::Box::<core::felt252>) <- core::box::into_box::<core::felt252>(v0)
End:
Return(v1)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::box::Box::<core::felt252>) <- 0.into_box()
End:
Return(v1)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Box struct const folding.
//! > test_runner_name
test_match_optimizer
//! > function
struct A {
a: felt252,
}
fn foo() -> Box<A> {
BoxTrait::new(A { a: 1 })
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: test::A) <- struct_construct(v0)
(v2: core::box::Box::<test::A>) <- core::box::into_box::<test::A>(v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: test::A) <- struct_construct(v0)
(v2: core::box::Box::<test::A>) <- { 1: core::felt252 }.into_box()
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Box enum const folding.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> Box<Option<felt252>> {
BoxTrait::new(Option::Some(2))
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::box::Box::<core::option::Option::<core::felt252>>) <- core::box::into_box::<core::option::Option::<core::felt252>>(v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::box::Box::<core::option::Option::<core::felt252>>) <- Option::Some(2).into_box()
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const non-zero.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
8 / 4
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 8
(v1: core::integer::u8) <- 4
End:
Match(match core::integer::u8_is_zero(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8, v11: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v12: (core::integer::u8,)) <- struct_construct(v10)
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v14) => blk4,
PanicResult::Err(v15) => blk5,
})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v14)
End:
Return(v18)
blk5:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v19)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 8
(v1: core::integer::u8) <- 4
(v2: core::zeroable::NonZero::<core::integer::u8>) <- NonZero(4)
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v11: core::integer::u8) <- 0
(v10: core::integer::u8) <- 2
(v12: (core::integer::u8,)) <- struct_construct(v10)
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v14) => blk4,
PanicResult::Err(v15) => blk5,
})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v14)
End:
Return(v18)
blk5:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v19)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const zero.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
x / 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_is_zero(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8, v11: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v12: (core::integer::u8,)) <- struct_construct(v10)
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v14) => blk4,
PanicResult::Err(v15) => blk5,
})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v14)
End:
Return(v18)
blk5:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v19)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8, v11: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v12: (core::integer::u8,)) <- struct_construct(v10)
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v14) => blk4,
PanicResult::Err(v15) => blk5,
})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v14)
End:
Return(v18)
blk5:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v19)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const u256 non-zero.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u256) -> u256 {
x / 4
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u256
blk0 (root):
Statements:
(v1: core::integer::u256) <- { 4: core::integer::u128, 0: core::integer::u128 }
End:
Match(match core::integer::u256_is_zero(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u256, v11: core::integer::u256, v12: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v12)
(v13: (core::integer::u256,)) <- struct_construct(v10)
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > after
Parameters: v0: core::integer::u256
blk0 (root):
Statements:
(v1: core::integer::u256) <- { 4: core::integer::u128, 0: core::integer::u128 }
(v2: core::zeroable::NonZero::<core::integer::u256>) <- NonZero({ 4: core::integer::u128, 0: core::integer::u128 })
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u256, v11: core::integer::u256, v12: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v12)
(v13: (core::integer::u256,)) <- struct_construct(v10)
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const u256 zero.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u256) -> u256 {
x / 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u256
blk0 (root):
Statements:
(v1: core::integer::u256) <- { 0: core::integer::u128, 0: core::integer::u128 }
End:
Match(match core::integer::u256_is_zero(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u256, v11: core::integer::u256, v12: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v12)
(v13: (core::integer::u256,)) <- struct_construct(v10)
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > after
Parameters: v0: core::integer::u256
blk0 (root):
Statements:
(v1: core::integer::u256) <- { 0: core::integer::u128, 0: core::integer::u128 }
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u256, v11: core::integer::u256, v12: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v12)
(v13: (core::integer::u256,)) <- struct_construct(v10)
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v9})
blk3:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Upcast const.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u128) -> u128 {
x / 1_u64.into()
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u128
blk0 (root):
Statements:
(v1: core::integer::u64) <- 1
(v2: core::integer::u128) <- core::integer::upcast::<core::integer::u64, core::integer::u128>(v1)
End:
Match(match core::integer::u128_is_zero(v2) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v3) => blk2,
})
blk1:
Statements:
(v4: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v5: core::felt252) <- 5420154128225384396790819266608
(v6: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v4, v5)
(v7: core::panics::Panic) <- struct_construct()
(v8: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v7, v6)
(v9: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: core::integer::u128, v12: core::integer::u128) <- core::integer::u128_safe_divmod(v0, v3)
(v13: (core::integer::u128,)) <- struct_construct(v11)
(v14: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v10})
blk3:
Statements:
End:
Match(match_enum(v10) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > after
Parameters: v0: core::integer::u128
blk0 (root):
Statements:
(v1: core::integer::u64) <- 1
(v2: core::integer::u128) <- 1
(v3: core::zeroable::NonZero::<core::integer::u128>) <- NonZero(1)
End:
Goto(blk2, {})
blk1:
Statements:
(v4: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v5: core::felt252) <- 5420154128225384396790819266608
(v6: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v4, v5)
(v7: core::panics::Panic) <- struct_construct()
(v8: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v7, v6)
(v9: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: core::integer::u128, v12: core::integer::u128) <- core::integer::u128_safe_divmod(v0, v3)
(v13: (core::integer::u128,)) <- struct_construct(v11)
(v14: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v13)
End:
Goto(blk3, {v14 -> v10})
blk3:
Statements:
End:
Match(match_enum(v10) {
PanicResult::Ok(v15) => blk4,
PanicResult::Err(v16) => blk5,
})
blk4:
Statements:
(v19: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v15)
End:
Return(v19)
blk5:
Statements:
(v20: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v16)
End:
Return(v20)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Downcast const success.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u64) -> u64 {
x / 1_u128.try_into().unwrap()
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u64
blk0 (root):
Statements:
(v1: core::integer::u128) <- 1
End:
Match(match core::integer::downcast::<core::integer::u128, core::integer::u64>(v1) {
Option::Some(v2) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v3: core::option::Option::<core::integer::u64>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::integer::u64>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Match(match_enum(v4) {
Option::Some(v7) => blk4,
Option::None(v8) => blk5,
})
blk4:
Statements:
(v9: (core::integer::u64,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v9)
End:
Goto(blk6, {v10 -> v11})
blk5:
Statements:
(v12: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v13: core::felt252) <- 29721761890975875353235833581453094220424382983267374
(v14: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v12, v13)
(v15: core::panics::Panic) <- struct_construct()
(v16: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v15, v14)
(v17: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v16)
End:
Goto(blk6, {v17 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v18) => blk7,
PanicResult::Err(v19) => blk13,
})
blk7:
Statements:
(v20: core::integer::u64) <- struct_destructure(v18)
End:
Match(match core::integer::u64_is_zero(v20) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v21) => blk9,
})
blk8:
Statements:
(v22: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v23: core::felt252) <- 5420154128225384396790819266608
(v24: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v22, v23)
(v25: core::panics::Panic) <- struct_construct()
(v26: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v25, v24)
(v27: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v26)
End:
Goto(blk10, {v27 -> v28})
blk9:
Statements:
(v29: core::integer::u64, v30: core::integer::u64) <- core::integer::u64_safe_divmod(v0, v21)
(v31: (core::integer::u64,)) <- struct_construct(v29)
(v32: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v31)
End:
Goto(blk10, {v32 -> v28})
blk10:
Statements:
End:
Match(match_enum(v28) {
PanicResult::Ok(v33) => blk11,
PanicResult::Err(v34) => blk12,
})
blk11:
Statements:
(v37: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v33)
End:
Return(v37)
blk12:
Statements:
(v38: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v34)
End:
Return(v38)
blk13:
Statements:
(v39: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v19)
End:
Return(v39)
//! > after
Parameters: v0: core::integer::u64
blk0 (root):
Statements:
(v1: core::integer::u128) <- 1
(v2: core::integer::u64) <- 1
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::option::Option::<core::integer::u64>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::integer::u64>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Match(match_enum(v4) {
Option::Some(v7) => blk4,
Option::None(v8) => blk5,
})
blk4:
Statements:
(v9: (core::integer::u64,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v9)
End:
Goto(blk6, {v10 -> v11})
blk5:
Statements:
(v12: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v13: core::felt252) <- 29721761890975875353235833581453094220424382983267374
(v14: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v12, v13)
(v15: core::panics::Panic) <- struct_construct()
(v16: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v15, v14)
(v17: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v16)
End:
Goto(blk6, {v17 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v18) => blk7,
PanicResult::Err(v19) => blk13,
})
blk7:
Statements:
(v20: core::integer::u64) <- struct_destructure(v18)
End:
Match(match core::integer::u64_is_zero(v20) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v21) => blk9,
})
blk8:
Statements:
(v22: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v23: core::felt252) <- 5420154128225384396790819266608
(v24: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v22, v23)
(v25: core::panics::Panic) <- struct_construct()
(v26: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v25, v24)
(v27: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v26)
End:
Goto(blk10, {v27 -> v28})
blk9:
Statements:
(v29: core::integer::u64, v30: core::integer::u64) <- core::integer::u64_safe_divmod(v0, v21)
(v31: (core::integer::u64,)) <- struct_construct(v29)
(v32: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v31)
End:
Goto(blk10, {v32 -> v28})
blk10:
Statements:
End:
Match(match_enum(v28) {
PanicResult::Ok(v33) => blk11,
PanicResult::Err(v34) => blk12,
})
blk11:
Statements:
(v37: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v33)
End:
Return(v37)
blk12:
Statements:
(v38: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v34)
End:
Return(v38)
blk13:
Statements:
(v39: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v19)
End:
Return(v39)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Downcast const failure.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
x / 300_u16.try_into().unwrap()
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u16) <- 300
End:
Match(match core::integer::downcast::<core::integer::u16, core::integer::u8>(v1) {
Option::Some(v2) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v3: core::option::Option::<core::integer::u8>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::integer::u8>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Match(match_enum(v4) {
Option::Some(v7) => blk4,
Option::None(v8) => blk5,
})
blk4:
Statements:
(v9: (core::integer::u8,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Goto(blk6, {v10 -> v11})
blk5:
Statements:
(v12: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v13: core::felt252) <- 29721761890975875353235833581453094220424382983267374
(v14: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v12, v13)
(v15: core::panics::Panic) <- struct_construct()
(v16: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v15, v14)
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v16)
End:
Goto(blk6, {v17 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v18) => blk7,
PanicResult::Err(v19) => blk13,
})
blk7:
Statements:
(v20: core::integer::u8) <- struct_destructure(v18)
End:
Match(match core::integer::u8_is_zero(v20) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v21) => blk9,
})
blk8:
Statements:
(v22: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v23: core::felt252) <- 5420154128225384396790819266608
(v24: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v22, v23)
(v25: core::panics::Panic) <- struct_construct()
(v26: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v25, v24)
(v27: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v26)
End:
Goto(blk10, {v27 -> v28})
blk9:
Statements:
(v29: core::integer::u8, v30: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v21)
(v31: (core::integer::u8,)) <- struct_construct(v29)
(v32: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk10, {v32 -> v28})
blk10:
Statements:
End:
Match(match_enum(v28) {
PanicResult::Ok(v33) => blk11,
PanicResult::Err(v34) => blk12,
})
blk11:
Statements:
(v37: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v33)
End:
Return(v37)
blk12:
Statements:
(v38: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v34)
End:
Return(v38)
blk13:
Statements:
(v39: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v19)
End:
Return(v39)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u16) <- 300
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::option::Option::<core::integer::u8>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::integer::u8>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Match(match_enum(v4) {
Option::Some(v7) => blk4,
Option::None(v8) => blk5,
})
blk4:
Statements:
(v9: (core::integer::u8,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Goto(blk6, {v10 -> v11})
blk5:
Statements:
(v12: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v13: core::felt252) <- 29721761890975875353235833581453094220424382983267374
(v14: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v12, v13)
(v15: core::panics::Panic) <- struct_construct()
(v16: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v15, v14)
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v16)
End:
Goto(blk6, {v17 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v18) => blk7,
PanicResult::Err(v19) => blk13,
})
blk7:
Statements:
(v20: core::integer::u8) <- struct_destructure(v18)
End:
Match(match core::integer::u8_is_zero(v20) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v21) => blk9,
})
blk8:
Statements:
(v22: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v23: core::felt252) <- 5420154128225384396790819266608
(v24: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v22, v23)
(v25: core::panics::Panic) <- struct_construct()
(v26: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v25, v24)
(v27: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v26)
End:
Goto(blk10, {v27 -> v28})
blk9:
Statements:
(v29: core::integer::u8, v30: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v21)
(v31: (core::integer::u8,)) <- struct_construct(v29)
(v32: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk10, {v32 -> v28})
blk10:
Statements:
End:
Match(match_enum(v28) {
PanicResult::Ok(v33) => blk11,
PanicResult::Err(v34) => blk12,
})
blk11:
Statements:
(v37: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v33)
End:
Return(v37)
blk12:
Statements:
(v38: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v34)
End:
Return(v38)
blk13:
Statements:
(v39: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v19)
End:
Return(v39)
//! > lowering_diagnostics
//! > ==========================================================================
//! > StorageBaseAddress const.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> starknet::StorageBaseAddress {
starknet::storage_access::storage_base_address_from_felt252(10)
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 10
(v1: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_from_felt252(v0)
End:
Return(v1)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 10
(v1: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_const::<10>()
End:
Return(v1)
//! > lowering_diagnostics
//! > ==========================================================================
//! > complex StorageBaseAddress const.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> starknet::storage::StorageBaseAddress {
starknet::storage::StorageBase::<felt252> { __base_address__: 1337 }.deref().finalize()
}
//! > function_name
foo
//! > module_code
use starknet::storage::StoragePathTrait;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1337
(v1: core::starknet::storage::storage_base::StorageBase::<core::felt252>) <- struct_construct(v0)
(v2: core::starknet::storage::storage_base::StorageBase::<core::felt252>, v3: @core::starknet::storage::storage_base::StorageBase::<core::felt252>) <- snapshot(v1)
(v4: @core::felt252) <- struct_destructure(v3)
(v5: core::felt252) <- desnap(v4)
(v10: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_from_felt252(v5)
End:
Return(v10)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1337
(v1: core::starknet::storage::storage_base::StorageBase::<core::felt252>) <- struct_construct(v0)
(v2: core::starknet::storage::storage_base::StorageBase::<core::felt252>, v3: @core::starknet::storage::storage_base::StorageBase::<core::felt252>) <- snapshot(v1)
(v4: @core::felt252) <- struct_destructure(v3)
(v5: core::felt252) <- desnap(v4)
(v10: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_const::<1337>()
End:
Return(v10)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add success const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
1 + 3
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 3
End:
Match(match core::integer::u8_overflowing_add(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 3
(v2: core::integer::u8) <- 4
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
250 + 50
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 250
(v1: core::integer::u8) <- 50
End:
Match(match core::integer::u8_overflowing_add(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 250
(v1: core::integer::u8) <- 50
(v3: core::integer::u8) <- 44
End:
Goto(blk2, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub success const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
7 - 5
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 7
(v1: core::integer::u8) <- 5
End:
Match(match core::integer::u8_overflowing_sub(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 7
(v1: core::integer::u8) <- 5
(v2: core::integer::u8) <- 2
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
1 - 3
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 3
End:
Match(match core::integer::u8_overflowing_sub(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 3
(v3: core::integer::u8) <- 254
End:
Goto(blk2, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Mul const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
5 * 3
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 5
(v1: core::integer::u8) <- 3
(v2: core::integer::u16) <- core::integer::u8_wide_mul(v0, v1)
End:
Match(match core::integer::downcast::<core::integer::u16, core::integer::u8>(v2) {
Option::Some(v3) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v3)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642107937639184217240406363762551
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 5
(v1: core::integer::u8) <- 3
(v2: core::integer::u16) <- 15
(v3: core::integer::u8) <- 15
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v3)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642107937639184217240406363762551
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold success.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
-50 + 100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -50
(v1: core::integer::i8) <- 100
End:
Match(match core::integer::i8_overflowing_add_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -50
(v1: core::integer::i8) <- 100
(v2: core::integer::i8) <- 50
End:
Goto(blk1, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold overflow.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
100 + 100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- 100
End:
Match(match core::integer::i8_overflowing_add_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- 100
(v4: core::integer::i8) <- -56
End:
Goto(blk3, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold underflow.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
-100 + -100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -100
(v1: core::integer::i8) <- -100
End:
Match(match core::integer::i8_overflowing_add_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -100
(v1: core::integer::i8) <- -100
(v3: core::integer::i8) <- 56
End:
Goto(blk2, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861642726607774050179732954277506935
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334541900811616953421972584034167
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold success.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
50 - 100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 50
(v1: core::integer::i8) <- 100
End:
Match(match core::integer::i8_overflowing_sub_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 50
(v1: core::integer::i8) <- 100
(v2: core::integer::i8) <- -50
End:
Goto(blk1, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold overflow.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
100 - -100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- -100
End:
Match(match core::integer::i8_overflowing_sub_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- -100
(v4: core::integer::i8) <- -56
End:
Goto(blk3, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold underflow.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
-100 - 100
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -100
(v1: core::integer::i8) <- 100
End:
Match(match core::integer::i8_overflowing_sub_impl(v0, v1) {
SignedIntegerResult::InRange(v2) => blk1,
SignedIntegerResult::Underflow(v3) => blk2,
SignedIntegerResult::Overflow(v4) => blk3,
})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -100
(v1: core::integer::i8) <- 100
(v3: core::integer::i8) <- 56
End:
Goto(blk2, {})
blk1:
Statements:
(v5: (core::integer::i8,)) <- struct_construct(v2)
(v6: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v5)
End:
Goto(blk4, {v6 -> v7})
blk2:
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 139861644157973526622261446548040478583
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::panics::Panic) <- struct_construct()
(v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v11, v10)
(v13: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk4, {v13 -> v7})
blk3:
Statements:
(v14: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v15: core::felt252) <- 546334547492084087938116166309670775
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v19: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v18)
End:
Goto(blk4, {v19 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v20) => blk5,
PanicResult::Err(v21) => blk6,
})
blk5:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v20)
End:
Return(v24)
blk6:
Statements:
(v25: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Return(v25)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed diff const fold over.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> bool {
100_i8 < 90_i8
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- 90
End:
Match(match core::integer::i8_diff(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: ()) <- struct_construct()
(v5: core::bool) <- bool::False(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::bool) <- bool::True(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 100
(v1: core::integer::i8) <- 90
(v2: core::integer::u8) <- 10
End:
Goto(blk1, {})
blk1:
Statements:
(v4: ()) <- struct_construct()
(v5: core::bool) <- bool::False(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::bool) <- bool::True(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed diff const fold under.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> bool {
90_i8 < 100_i8
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 90
(v1: core::integer::i8) <- 100
End:
Match(match core::integer::i8_diff(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: ()) <- struct_construct()
(v5: core::bool) <- bool::False(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::bool) <- bool::True(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 90
(v1: core::integer::i8) <- 100
(v3: core::integer::u8) <- 246
End:
Goto(blk2, {})
blk1:
Statements:
(v4: ()) <- struct_construct()
(v5: core::bool) <- bool::False(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::bool) <- bool::True(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Construct with undroppable.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> bool {
let x: (felt252, Felt252Dict<felt252>) = (0, Default::<Felt252Dict>::default());
let (l, _) = @x;
*l == 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::dict::Felt252Dict::<core::felt252>) <- core::dict::felt252_dict_new::<core::felt252>()
(v2: (core::felt252, core::dict::Felt252Dict::<core::felt252>)) <- struct_construct(v0, v1)
(v3: (core::felt252, core::dict::Felt252Dict::<core::felt252>), v4: @(core::felt252, core::dict::Felt252Dict::<core::felt252>)) <- snapshot(v2)
(v5: core::felt252, v6: core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v3)
(v7: core::dict::SquashedFelt252Dict::<core::felt252>) <- core::dict::Felt252DictImpl::<core::felt252, core::Felt252Felt252DictValue>::squash(v6)
(v9: @core::felt252, v10: @core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v4)
(v11: core::felt252) <- desnap(v9)
(v14: core::felt252) <- 0
(v19: core::felt252) <- core::felt252_sub(v11, v14)
End:
Match(match core::felt252_is_zero(v19) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v20) => blk2,
})
blk1:
Statements:
(v21: ()) <- struct_construct()
(v22: core::bool) <- bool::True(v21)
End:
Goto(blk3, {v22 -> v23})
blk2:
Statements:
(v24: ()) <- struct_construct()
(v25: core::bool) <- bool::False(v24)
End:
Goto(blk3, {v25 -> v23})
blk3:
Statements:
End:
Return(v23)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::dict::Felt252Dict::<core::felt252>) <- core::dict::felt252_dict_new::<core::felt252>()
(v2: (core::felt252, core::dict::Felt252Dict::<core::felt252>)) <- struct_construct(v0, v1)
(v3: (core::felt252, core::dict::Felt252Dict::<core::felt252>), v4: @(core::felt252, core::dict::Felt252Dict::<core::felt252>)) <- snapshot(v2)
(v5: core::felt252, v6: core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v3)
(v7: core::dict::SquashedFelt252Dict::<core::felt252>) <- core::dict::Felt252DictImpl::<core::felt252, core::Felt252Felt252DictValue>::squash(v6)
(v9: @core::felt252, v10: @core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v4)
(v11: core::felt252) <- desnap(v9)
(v14: core::felt252) <- 0
(v19: core::felt252) <- core::felt252_sub(v11, v14)
End:
Goto(blk1, {})
blk1:
Statements:
(v21: ()) <- struct_construct()
(v22: core::bool) <- bool::True(v21)
End:
Goto(blk3, {v22 -> v23})
blk2:
Statements:
(v24: ()) <- struct_construct()
(v25: core::bool) <- bool::False(v24)
End:
Goto(blk3, {v25 -> v23})
blk3:
Statements:
End:
Return(v23)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const zero (bounded_int).
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: i8) -> i8 {
x / 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::i8
blk0 (root):
Statements:
(v1: core::integer::i8) <- 0
End:
Match(match core::internal::bounded_int::bounded_int_is_zero::<core::integer::i8>(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v7)
End:
Goto(blk5, {v8 -> v9})
blk2:
Statements:
(v10: core::panics::PanicResult::<((core::integer::i8, core::integer::i8),)>) <- core::integer::signed_div_rem::DivRemImpl::<core::integer::i8, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::MulMinus1::<0, 128, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<128, -128>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::MulMinus1::<0, 126, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<126, -126>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::integer::i8Drop, core::internal::bounded_int::BoundedIntDrop::<1, 128>, core::internal::bounded_int::BoundedIntDrop::<-128, -1>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 126>, core::internal::bounded_int::BoundedIntDrop::<0, 127>>::div_rem(v0, v2)
End:
Match(match_enum(v10) {
PanicResult::Ok(v11) => blk3,
PanicResult::Err(v12) => blk4,
})
blk3:
Statements:
(v13: (core::integer::i8, core::integer::i8)) <- struct_destructure(v11)
(v14: core::integer::i8, v15: core::integer::i8) <- struct_destructure(v13)
(v16: (core::integer::i8,)) <- struct_construct(v14)
(v17: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v16)
End:
Goto(blk5, {v17 -> v9})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk5, {v18 -> v9})
blk5:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v19) => blk6,
PanicResult::Err(v20) => blk7,
})
blk6:
Statements:
(v23: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Return(v23)
blk7:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v20)
End:
Return(v24)
//! > after
Parameters: v0: core::integer::i8
blk0 (root):
Statements:
(v1: core::integer::i8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v7)
End:
Goto(blk5, {v8 -> v9})
blk2:
Statements:
(v10: core::panics::PanicResult::<((core::integer::i8, core::integer::i8),)>) <- core::integer::signed_div_rem::DivRemImpl::<core::integer::i8, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::MulMinus1::<0, 128, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<128, -128>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::MulMinus1::<0, 126, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<126, -126>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::integer::i8Drop, core::internal::bounded_int::BoundedIntDrop::<1, 128>, core::internal::bounded_int::BoundedIntDrop::<-128, -1>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 126>, core::internal::bounded_int::BoundedIntDrop::<0, 127>>::div_rem(v0, v2)
End:
Match(match_enum(v10) {
PanicResult::Ok(v11) => blk3,
PanicResult::Err(v12) => blk4,
})
blk3:
Statements:
(v13: (core::integer::i8, core::integer::i8)) <- struct_destructure(v11)
(v14: core::integer::i8, v15: core::integer::i8) <- struct_destructure(v13)
(v16: (core::integer::i8,)) <- struct_construct(v14)
(v17: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v16)
End:
Goto(blk5, {v17 -> v9})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk5, {v18 -> v9})
blk5:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v19) => blk6,
PanicResult::Err(v20) => blk7,
})
blk6:
Statements:
(v23: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Return(v23)
blk7:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v20)
End:
Return(v24)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const non-zero (bounded_int).
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> i8 {
8 / 4
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 8
(v1: core::integer::i8) <- 4
End:
Match(match core::internal::bounded_int::bounded_int_is_zero::<core::integer::i8>(v1) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v2) => blk2,
})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v7)
End:
Goto(blk5, {v8 -> v9})
blk2:
Statements:
(v10: core::panics::PanicResult::<((core::integer::i8, core::integer::i8),)>) <- core::integer::signed_div_rem::DivRemImpl::<core::integer::i8, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::MulMinus1::<0, 128, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<128, -128>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::MulMinus1::<0, 126, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<126, -126>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::integer::i8Drop, core::internal::bounded_int::BoundedIntDrop::<1, 128>, core::internal::bounded_int::BoundedIntDrop::<-128, -1>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 126>, core::internal::bounded_int::BoundedIntDrop::<0, 127>>::div_rem(v0, v2)
End:
Match(match_enum(v10) {
PanicResult::Ok(v11) => blk3,
PanicResult::Err(v12) => blk4,
})
blk3:
Statements:
(v13: (core::integer::i8, core::integer::i8)) <- struct_destructure(v11)
(v14: core::integer::i8, v15: core::integer::i8) <- struct_destructure(v13)
(v16: (core::integer::i8,)) <- struct_construct(v14)
(v17: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v16)
End:
Goto(blk5, {v17 -> v9})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk5, {v18 -> v9})
blk5:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v19) => blk6,
PanicResult::Err(v20) => blk7,
})
blk6:
Statements:
(v23: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Return(v23)
blk7:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v20)
End:
Return(v24)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 8
(v1: core::integer::i8) <- 4
(v2: core::zeroable::NonZero::<core::integer::i8>) <- NonZero(4)
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v4: core::felt252) <- 5420154128225384396790819266608
(v5: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v3, v4)
(v6: core::panics::Panic) <- struct_construct()
(v7: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v6, v5)
(v8: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v7)
End:
Goto(blk5, {v8 -> v9})
blk2:
Statements:
(v10: core::panics::PanicResult::<((core::integer::i8, core::integer::i8),)>) <- core::integer::signed_div_rem::DivRemImpl::<core::integer::i8, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::integer::signed_div_rem::impls::DivRem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 127>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::MulMinus1::<0, 128, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<128, -128>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::MulMinus1::<0, 126, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<126, -126>>>, core::internal::bounded_int::MulMinusOneNegateHelper::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::MulMinus1::<0, 127, core::internal::bounded_int::neg_felt252::Impl::<0, 0>, core::internal::bounded_int::neg_felt252::Impl::<127, -127>>>, core::integer::i8Drop, core::internal::bounded_int::BoundedIntDrop::<1, 128>, core::internal::bounded_int::BoundedIntDrop::<-128, -1>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 127>, core::internal::bounded_int::BoundedIntDrop::<0, 126>, core::internal::bounded_int::BoundedIntDrop::<0, 127>>::div_rem(v0, v2)
End:
Match(match_enum(v10) {
PanicResult::Ok(v11) => blk3,
PanicResult::Err(v12) => blk4,
})
blk3:
Statements:
(v13: (core::integer::i8, core::integer::i8)) <- struct_destructure(v11)
(v14: core::integer::i8, v15: core::integer::i8) <- struct_destructure(v13)
(v16: (core::integer::i8,)) <- struct_construct(v14)
(v17: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v16)
End:
Goto(blk5, {v17 -> v9})
blk4:
Statements:
(v18: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v12)
End:
Goto(blk5, {v18 -> v9})
blk5:
Statements:
End:
Match(match_enum(v9) {
PanicResult::Ok(v19) => blk6,
PanicResult::Err(v20) => blk7,
})
blk6:
Statements:
(v23: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Return(v23)
blk7:
Statements:
(v24: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v20)
End:
Return(v24)
//! > lowering_diagnostics
//! > ==========================================================================
//! > `AbsAndSign` on positive const.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> (u8, bool) {
core::integer::AbsAndSign::<i8, u8>::abs_and_sign(6_i8)
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 6
End:
Match(match core::internal::bounded_int::bounded_int_constrain::<core::integer::i8, 0, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>>(v0) {
Result::Ok(v1) => blk1,
Result::Err(v2) => blk2,
})
blk1:
Statements:
(v3: core::internal::bounded_int::BoundedInt::<-1, -1>) <- core::internal::bounded_int::minus_1::const_as_immediate::<core::internal::bounded_int::minus_1::Const::<core::internal::bounded_int::BoundedInt::<-1, -1>, -1>>()
(v4: core::internal::bounded_int::BoundedInt::<1, 128>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::BoundedInt::<-1, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>(v1, v3)
(v5: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<1, 128>, core::integer::u8>(v4)
(v6: ()) <- struct_construct()
(v7: core::bool) <- bool::True(v6)
(v8: (core::integer::u8, core::bool)) <- struct_construct(v5, v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::u8>(v2)
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::False(v11)
(v13: (core::integer::u8, core::bool)) <- struct_construct(v10, v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Return(v9)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 6
(v2: core::internal::bounded_int::BoundedInt::<0, 127>) <- 6
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::internal::bounded_int::BoundedInt::<-1, -1>) <- core::internal::bounded_int::minus_1::const_as_immediate::<core::internal::bounded_int::minus_1::Const::<core::internal::bounded_int::BoundedInt::<-1, -1>, -1>>()
(v4: core::internal::bounded_int::BoundedInt::<1, 128>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::BoundedInt::<-1, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>(v1, v3)
(v5: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<1, 128>, core::integer::u8>(v4)
(v6: ()) <- struct_construct()
(v7: core::bool) <- bool::True(v6)
(v8: (core::integer::u8, core::bool)) <- struct_construct(v5, v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8) <- 6
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::False(v11)
(v13: (core::integer::u8, core::bool)) <- struct_construct(v10, v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Return(v9)
//! > lowering_diagnostics
//! > ==========================================================================
//! > `AbsAndSign` on negative const.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> (u8, bool) {
core::integer::AbsAndSign::<i8, u8>::abs_and_sign(-6_i8)
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -6
End:
Match(match core::internal::bounded_int::bounded_int_constrain::<core::integer::i8, 0, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>>(v0) {
Result::Ok(v1) => blk1,
Result::Err(v2) => blk2,
})
blk1:
Statements:
(v3: core::internal::bounded_int::BoundedInt::<-1, -1>) <- core::internal::bounded_int::minus_1::const_as_immediate::<core::internal::bounded_int::minus_1::Const::<core::internal::bounded_int::BoundedInt::<-1, -1>, -1>>()
(v4: core::internal::bounded_int::BoundedInt::<1, 128>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::BoundedInt::<-1, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>(v1, v3)
(v5: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<1, 128>, core::integer::u8>(v4)
(v6: ()) <- struct_construct()
(v7: core::bool) <- bool::True(v6)
(v8: (core::integer::u8, core::bool)) <- struct_construct(v5, v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::u8>(v2)
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::False(v11)
(v13: (core::integer::u8, core::bool)) <- struct_construct(v10, v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Return(v9)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -6
(v1: core::internal::bounded_int::BoundedInt::<-128, -1>) <- -6
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::internal::bounded_int::BoundedInt::<-1, -1>) <- core::internal::bounded_int::minus_1::const_as_immediate::<core::internal::bounded_int::minus_1::Const::<core::internal::bounded_int::BoundedInt::<-1, -1>, -1>>()
(v4: core::internal::bounded_int::BoundedInt::<1, 128>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<-128, -1>, core::internal::bounded_int::BoundedInt::<-1, -1>, core::internal::bounded_int::MulMinus1::<-128, -1, core::internal::bounded_int::neg_felt252::Impl::<-128, 128>, core::internal::bounded_int::neg_felt252::Impl::<-1, 1>>>(v1, v3)
(v5: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<1, 128>, core::integer::u8>(v4)
(v6: ()) <- struct_construct()
(v7: core::bool) <- bool::True(v6)
(v8: (core::integer::u8, core::bool)) <- struct_construct(v5, v7)
End:
Goto(blk3, {v8 -> v9})
blk2:
Statements:
(v10: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::u8>(v2)
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::False(v11)
(v13: (core::integer::u8, core::bool)) <- struct_construct(v10, v12)
End:
Goto(blk3, {v13 -> v9})
blk3:
Statements:
End:
Return(v9)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Bitwise not const folding.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> u8 {
~5
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 5
(v1: core::internal::bounded_int::BoundedInt::<255, 255>) <- 255
(v2: core::internal::bounded_int::BoundedInt::<0, 255>) <- core::internal::bounded_int::bounded_int_sub::<core::internal::bounded_int::BoundedInt::<255, 255>, core::integer::u8, core::integer::bitnot_impls::SubHelperImpl::<core::integer::u8, 255>>(v1, v0)
(v3: core::integer::u8) <- core::integer::upcast::<core::internal::bounded_int::BoundedInt::<0, 255>, core::integer::u8>(v2)
End:
Return(v3)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 5
(v1: core::internal::bounded_int::BoundedInt::<255, 255>) <- 255
(v2: core::internal::bounded_int::BoundedInt::<0, 255>) <- 250
(v3: core::integer::u8) <- 250
End:
Return(v3)
//! > lowering_diagnostics
//! > ==========================================================================
//! > bounded_int_constrain on NonZero below.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> Result<Box<NonZero<BoundedInt<-0x80, -1>>>, Box<NonZero<BoundedInt<0, 0x7f>>>> {
match core::internal::bounded_int::constrain::<NonZero<i8>, 0>(-5) {
Result::Ok(v) => Result::Ok(BoxTrait::new(v)),
Result::Err(v) => Result::Err(BoxTrait::new(v)),
}
}
//! > function_name
foo
//! > module_code
use core::internal::bounded_int::BoundedInt;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::zeroable::NonZero::<core::integer::i8>) <- NonZero(-5)
End:
Match(match core::internal::bounded_int::bounded_int_constrain::<core::zeroable::NonZero::<core::integer::i8>, 0, core::internal::bounded_int::NonZeroConstrainHelper::<core::integer::i8, 0, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>>>(v0) {
Result::Ok(v1) => blk1,
Result::Err(v2) => blk2,
})
blk1:
Statements:
(v3: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>(v1)
(v4: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Ok(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>(v2)
(v7: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Err(v6)
End:
Goto(blk3, {v7 -> v5})
blk3:
Statements:
End:
Return(v5)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::zeroable::NonZero::<core::integer::i8>) <- NonZero(-5)
(v1: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>) <- NonZero(-5)
End:
Goto(blk1, {})
blk1:
Statements:
(v3: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>) <- NonZero(-5).into_box()
(v4: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Ok(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>(v2)
(v7: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Err(v6)
End:
Goto(blk3, {v7 -> v5})
blk3:
Statements:
End:
Return(v5)
//! > lowering_diagnostics
//! > ==========================================================================
//! > bounded_int_constrain on NonZero above.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> Result<Box<NonZero<BoundedInt<-0x80, -1>>>, Box<NonZero<BoundedInt<0, 0x7f>>>> {
match core::internal::bounded_int::constrain::<NonZero<i8>, 0>(5) {
Result::Ok(v) => Result::Ok(BoxTrait::new(v)),
Result::Err(v) => Result::Err(BoxTrait::new(v)),
}
}
//! > function_name
foo
//! > module_code
use core::internal::bounded_int::BoundedInt;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::zeroable::NonZero::<core::integer::i8>) <- NonZero(5)
End:
Match(match core::internal::bounded_int::bounded_int_constrain::<core::zeroable::NonZero::<core::integer::i8>, 0, core::internal::bounded_int::NonZeroConstrainHelper::<core::integer::i8, 0, core::internal::bounded_int::constrain0::Impl::<core::integer::i8, -128, 127>>>(v0) {
Result::Ok(v1) => blk1,
Result::Err(v2) => blk2,
})
blk1:
Statements:
(v3: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>(v1)
(v4: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Ok(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>(v2)
(v7: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Err(v6)
End:
Goto(blk3, {v7 -> v5})
blk3:
Statements:
End:
Return(v5)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::zeroable::NonZero::<core::integer::i8>) <- NonZero(5)
(v2: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>) <- NonZero(5)
End:
Goto(blk2, {})
blk1:
Statements:
(v3: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>) <- core::box::into_box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>(v1)
(v4: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Ok(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>) <- NonZero(5).into_box()
(v7: core::result::Result::<core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>>, core::box::Box::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>>>) <- Result::Err(v6)
End:
Goto(blk3, {v7 -> v5})
blk3:
Statements:
End:
Return(v5)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Eq const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> bool {
1_u8 == 1
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v3: core::integer::u8) <- 1
End:
Match(match core::integer::u8_eq(v0, v3) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v3: core::integer::u8) <- 1
End:
Goto(blk2, {})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Non eq const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo() -> bool {
2_u8 == 1
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 2
(v3: core::integer::u8) <- 1
End:
Match(match core::integer::u8_eq(v0, v3) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 2
(v3: core::integer::u8) <- 1
End:
Goto(blk1, {})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Mul 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
x * 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
(v2: core::integer::u16) <- core::integer::u8_wide_mul(v0, v1)
End:
Match(match core::integer::downcast::<core::integer::u16, core::integer::u8>(v2) {
Option::Some(v3) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v3)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642107937639184217240406363762551
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
(v2: core::integer::u16) <- 0
(v3: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v3)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642107937639184217240406363762551
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
x + 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_overflowing_add(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v0)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add to 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
0 + x
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_overflowing_add(v1, v0) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v0)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642104203229548495787928534675319
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> u8 {
x - 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_overflowing_sub(v0, v1) {
Result::Ok(v2) => blk1,
Result::Err(v3) => blk2,
})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v2)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v4: (core::integer::u8,)) <- struct_construct(v0)
(v5: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v8: core::felt252) <- 608642109794502019480482122260311927
(v9: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v7, v8)
(v10: core::panics::Panic) <- struct_construct()
(v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v10, v9)
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Goto(blk3, {v12 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v13) => blk4,
PanicResult::Err(v14) => blk5,
})
blk4:
Statements:
(v17: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v13)
End:
Return(v17)
blk5:
Statements:
(v18: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v14)
End:
Return(v18)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Eq with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function
fn foo(x: u8) -> bool {
x == 0
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v3: core::integer::u8) <- 0
End:
Match(match core::integer::u8_eq(v0, v3) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v3: core::integer::u8) <- 0
End:
Match(match core::integer::u8_is_zero(v0) {
IsZeroResult::Zero => blk2,
IsZeroResult::NonZero(v13) => blk1,
})
blk1:
Statements:
(v8: ()) <- struct_construct()
(v9: core::bool) <- bool::False(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::bool) <- bool::True(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > lowering_diagnostics