//! > Test const folding simple scenario.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(a: felt252) -> felt252 {
let b = a - 0;
b - 0
}
//! > function_name
foo
//! > 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)
//! > ==========================================================================
//! > Felt252 add overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
PRIME_MINUS_1 + 2
}
//! > function_name
foo
//! > module_code
const PRIME_MINUS_1: felt252 = -1;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- core::felt252_add(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- 1
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 sub overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
0 - 1
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::felt252) <- 1
(v2: core::felt252) <- core::felt252_sub(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::felt252) <- 1
(v2: core::felt252) <- -1
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 mul overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
PRIME_MINUS_1 * 2
}
//! > function_name
foo
//! > module_code
const PRIME_MINUS_1: felt252 = -1;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- core::felt252_mul(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- -2
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 combined overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
(PRIME_MINUS_1 + 2) * 2
}
//! > function_name
foo
//! > module_code
const PRIME_MINUS_1: felt252 = -1;
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- core::felt252_add(v0, v1)
(v3: core::felt252) <- 2
(v4: core::felt252) <- core::felt252_mul(v2, v3)
End:
Return(v4)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- -1
(v1: core::felt252) <- 2
(v2: core::felt252) <- 1
(v3: core::felt252) <- 2
(v4: core::felt252) <- core::felt252_mul(v2, v3)
End:
Return(v3)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Basic box const folding.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Box<felt252> {
BoxTrait::new(0)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 0
(v1: core::box::Box::<core::felt252>) <- into_box(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_code
struct A {
a: felt252,
}
fn foo() -> Box<A> {
BoxTrait::new(A { a: 1 })
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: test::A) <- struct_construct(v0)
(v2: core::box::Box::<test::A>) <- into_box(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_code
fn foo() -> Box<Option<felt252>> {
BoxTrait::new(Some(2))
}
//! > function_name
foo
//! > 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>>) <- into_box(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
//! > ==========================================================================
//! > Box unbox const folding.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
BoxTrait::new(2).unbox()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::box::Box::<core::felt252>) <- into_box(v0)
(v2: core::felt252) <- unbox(v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::box::Box::<core::felt252>) <- 2.into_box()
(v2: core::felt252) <- 2
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const non-zero.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
8 / 4
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u8, v7: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v8: (core::integer::u8,)) <- struct_construct(v6)
(v9: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v8)
End:
Goto(blk3, {v9 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v10) => blk4,
PanicResult::Err(v11) => blk5,
})
blk4:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v10)
End:
Return(v12)
blk5:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Return(v13)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v7: core::integer::u8) <- 0
(v6: core::integer::u8) <- 2
(v8: (core::integer::u8,)) <- struct_construct(v6)
(v9: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v8)
End:
Goto(blk3, {v9 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v10) => blk4,
PanicResult::Err(v11) => blk5,
})
blk4:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v10)
End:
Return(v12)
blk5:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Return(v13)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const zero.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x / 0
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u8, v7: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v8: (core::integer::u8,)) <- struct_construct(v6)
(v9: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v8)
End:
Goto(blk3, {v9 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v10) => blk4,
PanicResult::Err(v11) => blk5,
})
blk4:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v10)
End:
Return(v12)
blk5:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Return(v13)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v3: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u8, v7: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v2)
(v8: (core::integer::u8,)) <- struct_construct(v6)
(v9: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v8)
End:
Goto(blk3, {v9 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v10) => blk4,
PanicResult::Err(v11) => blk5,
})
blk4:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v10)
End:
Return(v12)
blk5:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v11)
End:
Return(v13)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const u256 non-zero.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u256) -> u256 {
x / 4
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u256, v7: core::integer::u256, v8: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v8)
(v9: (core::integer::u256,)) <- struct_construct(v6)
(v10: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u256, v7: core::integer::u256, v8: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v8)
(v9: (core::integer::u256,)) <- struct_construct(v6)
(v10: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const u256 zero.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u256) -> u256 {
x / 0
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u256, v7: core::integer::u256, v8: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v8)
(v9: (core::integer::u256,)) <- struct_construct(v6)
(v10: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v3)
End:
Goto(blk3, {v4 -> v5})
blk2:
Statements:
(v6: core::integer::u256, v7: core::integer::u256, v8: core::integer::U128MulGuarantee) <- core::integer::u256_safe_divmod(v0, v2)
() <- core::integer::u128_mul_guarantee_verify(v8)
(v9: (core::integer::u256,)) <- struct_construct(v6)
(v10: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v5})
blk3:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u256,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Upcast const.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u128) -> u128 {
x / 1_u64.into()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u128
blk0 (root):
Statements:
(v1: core::integer::u64) <- 1
(v2: core::integer::u128) <- core::internal::bounded_int::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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v5: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::integer::u128, v8: core::integer::u128) <- core::integer::u128_safe_divmod(v0, v3)
(v9: (core::integer::u128,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v5: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: core::integer::u128, v8: core::integer::u128) <- core::integer::u128_safe_divmod(v0, v3)
(v9: (core::integer::u128,)) <- struct_construct(v7)
(v10: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v9)
End:
Goto(blk3, {v10 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v11) => blk4,
PanicResult::Err(v12) => blk5,
})
blk4:
Statements:
(v13: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v11)
End:
Return(v13)
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Err(v12)
End:
Return(v14)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Downcast const success.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u64) -> u64 {
x / 1_u128.try_into().unwrap()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u64
blk0 (root):
Statements:
(v1: core::integer::u128) <- 1
End:
Match(match core::internal::bounded_int::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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<29721761890975875353235833581453094220424382983267374>()
(v13: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v12)
End:
Goto(blk6, {v13 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v14) => blk7,
PanicResult::Err(v15) => blk13,
})
blk7:
Statements:
(v16: core::integer::u64) <- struct_destructure(v14)
End:
Match(match core::integer::u64_is_zero(v16) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v17) => blk9,
})
blk8:
Statements:
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v19: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v18)
End:
Goto(blk10, {v19 -> v20})
blk9:
Statements:
(v21: core::integer::u64, v22: core::integer::u64) <- core::integer::u64_safe_divmod(v0, v17)
(v23: (core::integer::u64,)) <- struct_construct(v21)
(v24: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v23)
End:
Goto(blk10, {v24 -> v20})
blk10:
Statements:
End:
Match(match_enum(v20) {
PanicResult::Ok(v25) => blk11,
PanicResult::Err(v26) => blk12,
})
blk11:
Statements:
(v27: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v25)
End:
Return(v27)
blk12:
Statements:
(v28: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v26)
End:
Return(v28)
blk13:
Statements:
(v29: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v15)
End:
Return(v29)
//! > 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:
(v7: core::integer::u64) <- 1
End:
Goto(blk4, {})
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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<29721761890975875353235833581453094220424382983267374>()
(v13: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v12)
End:
Goto(blk6, {v13 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v14) => blk7,
PanicResult::Err(v15) => blk13,
})
blk7:
Statements:
(v16: core::integer::u64) <- struct_destructure(v14)
(v17: core::zeroable::NonZero::<core::integer::u64>) <- NonZero(1)
End:
Goto(blk9, {})
blk8:
Statements:
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v19: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v18)
End:
Goto(blk10, {v19 -> v20})
blk9:
Statements:
(v21: core::integer::u64, v22: core::integer::u64) <- core::integer::u64_safe_divmod(v0, v17)
(v23: (core::integer::u64,)) <- struct_construct(v21)
(v24: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v23)
End:
Goto(blk10, {v24 -> v20})
blk10:
Statements:
End:
Match(match_enum(v20) {
PanicResult::Ok(v25) => blk11,
PanicResult::Err(v26) => blk12,
})
blk11:
Statements:
(v27: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v25)
End:
Return(v27)
blk12:
Statements:
(v28: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v26)
End:
Return(v28)
blk13:
Statements:
(v29: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v15)
End:
Return(v29)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Downcast const failure.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x / 300_u16.try_into().unwrap()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u16) <- 300
End:
Match(match core::internal::bounded_int::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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<29721761890975875353235833581453094220424382983267374>()
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v12)
End:
Goto(blk6, {v13 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v14) => blk7,
PanicResult::Err(v15) => blk13,
})
blk7:
Statements:
(v16: core::integer::u8) <- struct_destructure(v14)
End:
Match(match core::integer::u8_is_zero(v16) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v17) => blk9,
})
blk8:
Statements:
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v18)
End:
Goto(blk10, {v19 -> v20})
blk9:
Statements:
(v21: core::integer::u8, v22: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v17)
(v23: (core::integer::u8,)) <- struct_construct(v21)
(v24: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v23)
End:
Goto(blk10, {v24 -> v20})
blk10:
Statements:
End:
Match(match_enum(v20) {
PanicResult::Ok(v25) => blk11,
PanicResult::Err(v26) => blk12,
})
blk11:
Statements:
(v27: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v25)
End:
Return(v27)
blk12:
Statements:
(v28: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v26)
End:
Return(v28)
blk13:
Statements:
(v29: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v29)
//! > 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:
(v8: ()) <- struct_construct()
End:
Goto(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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<29721761890975875353235833581453094220424382983267374>()
(v13: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v12)
End:
Goto(blk6, {v13 -> v11})
blk6:
Statements:
End:
Match(match_enum(v11) {
PanicResult::Ok(v14) => blk7,
PanicResult::Err(v15) => blk13,
})
blk7:
Statements:
(v16: core::integer::u8) <- struct_destructure(v14)
End:
Match(match core::integer::u8_is_zero(v16) {
IsZeroResult::Zero => blk8,
IsZeroResult::NonZero(v17) => blk9,
})
blk8:
Statements:
(v18: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v19: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v18)
End:
Goto(blk10, {v19 -> v20})
blk9:
Statements:
(v21: core::integer::u8, v22: core::integer::u8) <- core::integer::u8_safe_divmod(v0, v17)
(v23: (core::integer::u8,)) <- struct_construct(v21)
(v24: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v23)
End:
Goto(blk10, {v24 -> v20})
blk10:
Statements:
End:
Match(match_enum(v20) {
PanicResult::Ok(v25) => blk11,
PanicResult::Err(v26) => blk12,
})
blk11:
Statements:
(v27: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v25)
End:
Return(v27)
blk12:
Statements:
(v28: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v26)
End:
Return(v28)
blk13:
Statements:
(v29: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v15)
End:
Return(v29)
//! > lowering_diagnostics
//! > ==========================================================================
//! > StorageBaseAddress const.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> starknet::StorageBaseAddress {
starknet::storage_access::storage_base_address_from_felt252(10)
}
//! > function_name
foo
//! > 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_code
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)
(v6: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_from_felt252(v5)
End:
Return(v6)
//! > 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)
(v6: core::starknet::storage_access::StorageBaseAddress) <- core::starknet::storage_access::storage_base_address_const::<1337>()
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add success const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
1 + 3
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
250 + 50
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub success const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
7 - 5
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub overflow const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
1 - 3
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Mul const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
5 * 3
}
//! > function_name
foo
//! > 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::internal::bounded_int::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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642107937639184217240406363762551>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642107937639184217240406363762551>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold success.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
-50 + 100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold overflow.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
100 + 100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed add const fold underflow.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
-100 + -100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861642726607774050179732954277506935>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334541900811616953421972584034167>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold success.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
50 - 100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold overflow.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
100 - -100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed sub const fold underflow.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
-100 - 100
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<139861644157973526622261446548040478583>()
(v9: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v8)
End:
Goto(blk4, {v9 -> v7})
blk3:
Statements:
(v10: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<546334547492084087938116166309670775>()
(v11: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v10)
End:
Goto(blk4, {v11 -> v7})
blk4:
Statements:
End:
Match(match_enum(v7) {
PanicResult::Ok(v12) => blk5,
PanicResult::Err(v13) => blk6,
})
blk5:
Statements:
(v14: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v12)
End:
Return(v14)
blk6:
Statements:
(v15: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v13)
End:
Return(v15)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Signed diff const fold over.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> bool {
100_i8 < 90_i8
}
//! > function_name
foo
//! > 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_code
fn foo() -> bool {
90_i8 < 100_i8
}
//! > function_name
foo
//! > 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_code
fn foo() -> bool {
let x: (felt252, Felt252Dict<felt252>) = (0, Default::<Felt252Dict>::default());
let (l, _) = @x;
*l == 0
}
//! > function_name
foo
//! > 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)
(v8: @core::felt252, v9: @core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v4)
(v10: core::felt252) <- 0
(v11: core::felt252) <- desnap(v8)
(v12: core::felt252) <- core::felt252_sub(v11, v10)
End:
Match(match core::felt252_is_zero(v12) {
IsZeroResult::Zero => blk1,
IsZeroResult::NonZero(v13) => blk2,
})
blk1:
Statements:
(v14: ()) <- struct_construct()
(v15: core::bool) <- bool::True(v14)
End:
Goto(blk3, {v15 -> v16})
blk2:
Statements:
(v17: ()) <- struct_construct()
(v18: core::bool) <- bool::False(v17)
End:
Goto(blk3, {v18 -> v16})
blk3:
Statements:
End:
Return(v16)
//! > 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)
(v8: @core::felt252, v9: @core::dict::Felt252Dict::<core::felt252>) <- struct_destructure(v4)
(v10: core::felt252) <- 0
(v11: core::felt252) <- desnap(v8)
(v12: core::felt252) <- core::felt252_sub(v11, v10)
End:
Goto(blk1, {})
blk1:
Statements:
(v14: ()) <- struct_construct()
(v15: core::bool) <- bool::True(v14)
End:
Goto(blk3, {v15 -> v16})
blk2:
Statements:
(v17: ()) <- struct_construct()
(v18: core::bool) <- bool::False(v17)
End:
Goto(blk3, {v18 -> v16})
blk3:
Statements:
End:
Return(v16)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const zero (bounded_int).
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: i8) -> i8 {
x / 0
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v3)
End:
Goto(blk11, {v4 -> v5})
blk2:
Statements:
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(v6) => blk3,
Result::Err(v7) => blk8,
})
blk3:
Statements:
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>>>(v2) {
Result::Ok(v8) => blk4,
Result::Err(v9) => blk7,
})
blk4:
Statements:
(v10: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v11: 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>>>(v6, v10)
(v12: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v13: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v8, v12)
(v14: core::internal::bounded_int::BoundedInt::<0, 128>, v15: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v11, v13)
End:
Match(match core::internal::bounded_int::downcast::<core::internal::bounded_int::BoundedInt::<0, 128>, core::integer::i8>(v14) {
Option::Some(v16) => blk5,
Option::None => blk6,
})
blk5:
Statements:
(v17: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v15, v10)
(v18: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v17)
(v19: (core::integer::i8,)) <- struct_construct(v16)
(v20: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Goto(blk11, {v20 -> v5})
blk6:
Statements:
(v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<172187905895106538554965390496552885916079950910267434855917956435901443959>()
(v22: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Goto(blk11, {v22 -> v5})
blk7:
Statements:
(v23: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v24: 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>>>(v6, v23)
(v25: core::internal::bounded_int::BoundedInt::<0, 128>, v26: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, 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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v24, v9)
(v27: core::internal::bounded_int::BoundedInt::<-128, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v25, v23)
(v28: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 0>, core::integer::i8>(v27)
(v29: core::internal::bounded_int::BoundedInt::<-126, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v26, v23)
(v30: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-126, 0>, core::integer::i8>(v29)
(v31: (core::integer::i8,)) <- struct_construct(v28)
(v32: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk11, {v32 -> v5})
blk8:
Statements:
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>>>(v2) {
Result::Ok(v33) => blk9,
Result::Err(v34) => blk10,
})
blk9:
Statements:
(v35: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v36: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v33, v35)
(v37: core::internal::bounded_int::BoundedInt::<0, 127>, v38: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v7, v36)
(v39: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v40: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v37, v39)
(v41: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v40)
(v42: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v38)
(v43: (core::integer::i8,)) <- struct_construct(v41)
(v44: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v43)
End:
Goto(blk11, {v44 -> v5})
blk10:
Statements:
(v45: core::internal::bounded_int::BoundedInt::<0, 127>, v46: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v7, v34)
(v47: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v45)
(v48: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 126>, core::integer::i8>(v46)
(v49: (core::integer::i8,)) <- struct_construct(v47)
(v50: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v49)
End:
Goto(blk11, {v50 -> v5})
blk11:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v51) => blk12,
PanicResult::Err(v52) => blk13,
})
blk12:
Statements:
(v53: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v51)
End:
Return(v53)
blk13:
Statements:
(v54: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v52)
End:
Return(v54)
//! > after
Parameters: v0: core::integer::i8
blk0 (root):
Statements:
(v1: core::integer::i8) <- 0
End:
Goto(blk1, {})
blk1:
Statements:
(v3: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v3)
End:
Goto(blk11, {v4 -> v5})
blk2:
Statements:
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(v6) => blk3,
Result::Err(v7) => blk8,
})
blk3:
Statements:
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>>>(v2) {
Result::Ok(v8) => blk4,
Result::Err(v9) => blk7,
})
blk4:
Statements:
(v10: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v11: 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>>>(v6, v10)
(v12: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v13: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v8, v12)
(v14: core::internal::bounded_int::BoundedInt::<0, 128>, v15: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v11, v13)
End:
Match(match core::internal::bounded_int::downcast::<core::internal::bounded_int::BoundedInt::<0, 128>, core::integer::i8>(v14) {
Option::Some(v16) => blk5,
Option::None => blk6,
})
blk5:
Statements:
(v17: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v15, v10)
(v18: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v17)
(v19: (core::integer::i8,)) <- struct_construct(v16)
(v20: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Goto(blk11, {v20 -> v5})
blk6:
Statements:
(v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<172187905895106538554965390496552885916079950910267434855917956435901443959>()
(v22: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Goto(blk11, {v22 -> v5})
blk7:
Statements:
(v23: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v24: 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>>>(v6, v23)
(v25: core::internal::bounded_int::BoundedInt::<0, 128>, v26: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, 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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v24, v9)
(v27: core::internal::bounded_int::BoundedInt::<-128, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v25, v23)
(v28: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 0>, core::integer::i8>(v27)
(v29: core::internal::bounded_int::BoundedInt::<-126, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v26, v23)
(v30: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-126, 0>, core::integer::i8>(v29)
(v31: (core::integer::i8,)) <- struct_construct(v28)
(v32: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk11, {v32 -> v5})
blk8:
Statements:
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>>>(v2) {
Result::Ok(v33) => blk9,
Result::Err(v34) => blk10,
})
blk9:
Statements:
(v35: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v36: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v33, v35)
(v37: core::internal::bounded_int::BoundedInt::<0, 127>, v38: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v7, v36)
(v39: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v40: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v37, v39)
(v41: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v40)
(v42: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v38)
(v43: (core::integer::i8,)) <- struct_construct(v41)
(v44: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v43)
End:
Goto(blk11, {v44 -> v5})
blk10:
Statements:
(v45: core::internal::bounded_int::BoundedInt::<0, 127>, v46: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v7, v34)
(v47: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v45)
(v48: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 126>, core::integer::i8>(v46)
(v49: (core::integer::i8,)) <- struct_construct(v47)
(v50: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v49)
End:
Goto(blk11, {v50 -> v5})
blk11:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v51) => blk12,
PanicResult::Err(v52) => blk13,
})
blk12:
Statements:
(v53: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v51)
End:
Return(v53)
blk13:
Statements:
(v54: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v52)
End:
Return(v54)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Division by const non-zero (bounded_int).
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> i8 {
8 / 4
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v3)
End:
Goto(blk11, {v4 -> v5})
blk2:
Statements:
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(v6) => blk3,
Result::Err(v7) => blk8,
})
blk3:
Statements:
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>>>(v2) {
Result::Ok(v8) => blk4,
Result::Err(v9) => blk7,
})
blk4:
Statements:
(v10: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v11: 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>>>(v6, v10)
(v12: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v13: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v8, v12)
(v14: core::internal::bounded_int::BoundedInt::<0, 128>, v15: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v11, v13)
End:
Match(match core::internal::bounded_int::downcast::<core::internal::bounded_int::BoundedInt::<0, 128>, core::integer::i8>(v14) {
Option::Some(v16) => blk5,
Option::None => blk6,
})
blk5:
Statements:
(v17: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v15, v10)
(v18: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v17)
(v19: (core::integer::i8,)) <- struct_construct(v16)
(v20: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Goto(blk11, {v20 -> v5})
blk6:
Statements:
(v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<172187905895106538554965390496552885916079950910267434855917956435901443959>()
(v22: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Goto(blk11, {v22 -> v5})
blk7:
Statements:
(v23: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v24: 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>>>(v6, v23)
(v25: core::internal::bounded_int::BoundedInt::<0, 128>, v26: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, 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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v24, v9)
(v27: core::internal::bounded_int::BoundedInt::<-128, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v25, v23)
(v28: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 0>, core::integer::i8>(v27)
(v29: core::internal::bounded_int::BoundedInt::<-126, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v26, v23)
(v30: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-126, 0>, core::integer::i8>(v29)
(v31: (core::integer::i8,)) <- struct_construct(v28)
(v32: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk11, {v32 -> v5})
blk8:
Statements:
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>>>(v2) {
Result::Ok(v33) => blk9,
Result::Err(v34) => blk10,
})
blk9:
Statements:
(v35: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v36: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v33, v35)
(v37: core::internal::bounded_int::BoundedInt::<0, 127>, v38: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v7, v36)
(v39: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v40: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v37, v39)
(v41: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v40)
(v42: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v38)
(v43: (core::integer::i8,)) <- struct_construct(v41)
(v44: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v43)
End:
Goto(blk11, {v44 -> v5})
blk10:
Statements:
(v45: core::internal::bounded_int::BoundedInt::<0, 127>, v46: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v7, v34)
(v47: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v45)
(v48: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 126>, core::integer::i8>(v46)
(v49: (core::integer::i8,)) <- struct_construct(v47)
(v50: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v49)
End:
Goto(blk11, {v50 -> v5})
blk11:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v51) => blk12,
PanicResult::Err(v52) => blk13,
})
blk12:
Statements:
(v53: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v51)
End:
Return(v53)
blk13:
Statements:
(v54: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v52)
End:
Return(v54)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<5420154128225384396790819266608>()
(v4: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v3)
End:
Goto(blk11, {v4 -> v5})
blk2:
Statements:
(v7: core::internal::bounded_int::BoundedInt::<0, 127>) <- 8
End:
Goto(blk8, {})
blk3:
Statements:
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>>>(v2) {
Result::Ok(v8) => blk4,
Result::Err(v9) => blk7,
})
blk4:
Statements:
(v10: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v11: 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>>>(v6, v10)
(v12: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v13: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v8, v12)
(v14: core::internal::bounded_int::BoundedInt::<0, 128>, v15: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v11, v13)
End:
Match(match core::internal::bounded_int::downcast::<core::internal::bounded_int::BoundedInt::<0, 128>, core::integer::i8>(v14) {
Option::Some(v16) => blk5,
Option::None => blk6,
})
blk5:
Statements:
(v17: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v15, v10)
(v18: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v17)
(v19: (core::integer::i8,)) <- struct_construct(v16)
(v20: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v19)
End:
Goto(blk11, {v20 -> v5})
blk6:
Statements:
(v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<172187905895106538554965390496552885916079950910267434855917956435901443959>()
(v22: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v21)
End:
Goto(blk11, {v22 -> v5})
blk7:
Statements:
(v23: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v24: 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>>>(v6, v23)
(v25: core::internal::bounded_int::BoundedInt::<0, 128>, v26: core::internal::bounded_int::BoundedInt::<0, 126>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<1, 128>, 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::<0, 127>, core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<0, 126>>>(v24, v9)
(v27: core::internal::bounded_int::BoundedInt::<-128, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 128>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v25, v23)
(v28: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 0>, core::integer::i8>(v27)
(v29: core::internal::bounded_int::BoundedInt::<-126, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 126>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v26, v23)
(v30: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-126, 0>, core::integer::i8>(v29)
(v31: (core::integer::i8,)) <- struct_construct(v28)
(v32: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v31)
End:
Goto(blk11, {v32 -> v5})
blk8:
Statements:
(v34: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<0, 127>>) <- NonZero(4)
End:
Goto(blk10, {})
blk9:
Statements:
(v35: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>) <- NonZero(-1)
(v36: core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<1, 128>>) <- core::internal::bounded_int::bounded_int_mul::<core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-128, -1>>, core::zeroable::NonZero::<core::internal::bounded_int::BoundedInt::<-1, -1>>, core::internal::bounded_int::NonZeroMulHelper::<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>>>>(v33, v35)
(v37: core::internal::bounded_int::BoundedInt::<0, 127>, v38: core::internal::bounded_int::BoundedInt::<0, 127>) <- core::internal::bounded_int::bounded_int_div_rem::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<1, 128>, 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>>>(v7, v36)
(v39: core::internal::bounded_int::BoundedInt::<-1, -1>) <- -1
(v40: core::internal::bounded_int::BoundedInt::<-127, 0>) <- core::internal::bounded_int::bounded_int_mul::<core::internal::bounded_int::BoundedInt::<0, 127>, core::internal::bounded_int::BoundedInt::<-1, -1>, 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>>>(v37, v39)
(v41: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 0>, core::integer::i8>(v40)
(v42: core::integer::i8) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 127>, core::integer::i8>(v38)
(v43: (core::integer::i8,)) <- struct_construct(v41)
(v44: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v43)
End:
Goto(blk11, {v44 -> v5})
blk10:
Statements:
(v46: core::internal::bounded_int::BoundedInt::<0, 126>) <- 0
(v45: core::internal::bounded_int::BoundedInt::<0, 127>) <- 2
(v47: core::integer::i8) <- 2
(v48: core::integer::i8) <- 0
(v49: (core::integer::i8,)) <- struct_construct(v47)
(v50: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v49)
End:
Goto(blk11, {v50 -> v5})
blk11:
Statements:
End:
Match(match_enum(v5) {
PanicResult::Ok(v51) => blk12,
PanicResult::Err(v52) => blk13,
})
blk12:
Statements:
(v53: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Ok(v51)
End:
Return(v53)
blk13:
Statements:
(v54: core::panics::PanicResult::<(core::integer::i8,)>) <- PanicResult::Err(v52)
End:
Return(v54)
//! > lowering_diagnostics
//! > ==========================================================================
//! > `AbsAndSign` on positive const.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> (u8, bool) {
core::integer::AbsAndSign::<i8, u8>::abs_and_sign(6_i8)
}
//! > function_name
foo
//! > 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>) <- -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::internal::bounded_int::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::internal::bounded_int::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>) <- -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::internal::bounded_int::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_code
fn foo() -> (u8, bool) {
core::integer::AbsAndSign::<i8, u8>::abs_and_sign(-6_i8)
}
//! > function_name
foo
//! > 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>) <- -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::internal::bounded_int::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::internal::bounded_int::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>) <- -1
(v4: core::internal::bounded_int::BoundedInt::<1, 128>) <- 6
(v5: core::integer::u8) <- 6
(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::internal::bounded_int::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_code
fn foo() -> u8 {
~5
}
//! > function_name
foo
//! > 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::internal::bounded_int::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_code
#[feature("bounded-int-utils")]
fn foo() -> Result<Box<NonZero<BoundedInt<-0x80, -1>>>, Box<NonZero<BoundedInt<0, 0x7f>>>> {
match core::internal::bounded_int::constrain::<NonZero<i8>, 0>(-5) {
Ok(v) => Ok(BoxTrait::new(v)),
Err(v) => Err(BoxTrait::new(v)),
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
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>>>) <- into_box(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>>>) <- into_box(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>>>) <- into_box(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_code
#[feature("bounded-int-utils")]
fn foo() -> Result<Box<NonZero<BoundedInt<-0x80, -1>>>, Box<NonZero<BoundedInt<0, 0x7f>>>> {
match core::internal::bounded_int::constrain::<NonZero<i8>, 0>(5) {
Ok(v) => Ok(BoxTrait::new(v)),
Err(v) => Err(BoxTrait::new(v)),
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
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>>>) <- into_box(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>>>) <- into_box(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>>>) <- into_box(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_code
fn foo() -> bool {
1_u8 == 1
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 1
End:
Match(match core::integer::u8_eq(v0, v1) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 1
(v1: core::integer::u8) <- 1
End:
Goto(blk2, {})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Non eq const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> bool {
2_u8 == 1
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 2
(v1: core::integer::u8) <- 1
End:
Match(match core::integer::u8_eq(v0, v1) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::u8) <- 2
(v1: core::integer::u8) <- 1
End:
Goto(blk1, {})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Mul 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x * 0
}
//! > function_name
foo
//! > 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::internal::bounded_int::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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642107937639184217240406363762551>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642107937639184217240406363762551>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x + 0
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add to 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
0 + x
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x - 0
}
//! > function_name
foo
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > 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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Add const 1 fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x + 1
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 1
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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 1
(v13: core::result::Result::<core::integer::u8, core::integer::u8>) <- core::internal::num::u8_inc(v0)
End:
Match(match_enum(v13) {
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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642104203229548495787928534675319>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Sub const 1 fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> u8 {
x - 1
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 1
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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 1
(v13: core::result::Result::<core::integer::u8, core::integer::u8>) <- core::internal::num::u8_dec(v0)
End:
Match(match_enum(v13) {
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::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<608642109794502019480482122260311927>()
(v8: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Match(match_enum(v6) {
PanicResult::Ok(v9) => blk4,
PanicResult::Err(v10) => blk5,
})
blk4:
Statements:
(v11: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Ok(v9)
End:
Return(v11)
blk5:
Statements:
(v12: core::panics::PanicResult::<(core::integer::u8,)>) <- PanicResult::Err(v10)
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Eq with 0 const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: u8) -> bool {
x == 0
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_eq(v0, v1) {
bool::False => blk1,
bool::True => blk2,
})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::integer::u8) <- 0
End:
Match(match core::integer::u8_is_zero(v0) {
IsZeroResult::Zero => blk2,
IsZeroResult::NonZero(v7) => blk1,
})
blk1:
Statements:
(v2: ()) <- struct_construct()
(v3: core::bool) <- bool::False(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::bool) <- bool::True(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array get at known index 0.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: @Array<u8>) -> Option<Box<@u8>> {
x.get(0)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: @core::array::Array::<core::integer::u8>
blk0 (root):
Statements:
(v1: core::integer::u32) <- 0
End:
Match(match core::array::array_get::<core::integer::u8>(v0, v1) {
Option::Some(v2) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v3: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > after
Parameters: v0: @core::array::Array::<core::integer::u8>
blk0 (root):
Statements:
(v1: core::integer::u32) <- 0
End:
Match(match core::array::array_snapshot_pop_front::<core::integer::u8>(v0) {
Option::Some(v7, v2) => blk1,
Option::None(v8) => blk2,
})
blk1:
Statements:
(v3: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v2)
End:
Goto(blk3, {v3 -> v4})
blk2:
Statements:
(v5: ()) <- struct_construct()
(v6: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v5)
End:
Goto(blk3, {v6 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Propagate over trivial downcasts.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: BoundedInt<0, 10>) -> u8 {
match x {
0 => 1,
1 => 2,
2 => 3,
3 => 4,
4 => 5,
5 => 6,
6 => 7,
7 => 8,
8 => 9,
9 => 10,
10 => 11,
_ => 12,
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
use core::internal::bounded_int::BoundedInt;
//! > semantic_diagnostics
//! > before
Parameters: v0: core::internal::bounded_int::BoundedInt::<0, 10>
blk0 (root):
Statements:
End:
Match(match core::internal::bounded_int::downcast::<core::internal::bounded_int::BoundedInt::<0, 10>, core::internal::bounded_int::BoundedInt::<0, 10>>(v0) {
Option::Some(v1) => blk1,
Option::None => blk13,
})
blk1:
Statements:
End:
Match(match_enum.(v1) {
0(v2) => blk2,
1(v3) => blk3,
2(v4) => blk4,
3(v5) => blk5,
4(v6) => blk6,
5(v7) => blk7,
6(v8) => blk8,
7(v9) => blk9,
8(v10) => blk10,
9(v11) => blk11,
10(v12) => blk12,
})
blk2:
Statements:
(v13: core::integer::u8) <- 1
End:
Goto(blk14, {v13 -> v14})
blk3:
Statements:
(v15: core::integer::u8) <- 2
End:
Goto(blk14, {v15 -> v14})
blk4:
Statements:
(v16: core::integer::u8) <- 3
End:
Goto(blk14, {v16 -> v14})
blk5:
Statements:
(v17: core::integer::u8) <- 4
End:
Goto(blk14, {v17 -> v14})
blk6:
Statements:
(v18: core::integer::u8) <- 5
End:
Goto(blk14, {v18 -> v14})
blk7:
Statements:
(v19: core::integer::u8) <- 6
End:
Goto(blk14, {v19 -> v14})
blk8:
Statements:
(v20: core::integer::u8) <- 7
End:
Goto(blk14, {v20 -> v14})
blk9:
Statements:
(v21: core::integer::u8) <- 8
End:
Goto(blk14, {v21 -> v14})
blk10:
Statements:
(v22: core::integer::u8) <- 9
End:
Goto(blk14, {v22 -> v14})
blk11:
Statements:
(v23: core::integer::u8) <- 10
End:
Goto(blk14, {v23 -> v14})
blk12:
Statements:
(v24: core::integer::u8) <- 11
End:
Goto(blk14, {v24 -> v14})
blk13:
Statements:
(v25: core::integer::u8) <- 12
End:
Goto(blk14, {v25 -> v14})
blk14:
Statements:
End:
Return(v14)
//! > after
Parameters: v0: core::internal::bounded_int::BoundedInt::<0, 10>
blk0 (root):
Statements:
(v1: core::internal::bounded_int::BoundedInt::<0, 10>) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<0, 10>, core::internal::bounded_int::BoundedInt::<0, 10>>(v0)
End:
Goto(blk1, {})
blk1:
Statements:
End:
Match(match_enum.(v1) {
0(v2) => blk2,
1(v3) => blk3,
2(v4) => blk4,
3(v5) => blk5,
4(v6) => blk6,
5(v7) => blk7,
6(v8) => blk8,
7(v9) => blk9,
8(v10) => blk10,
9(v11) => blk11,
10(v12) => blk12,
})
blk2:
Statements:
(v13: core::integer::u8) <- 1
End:
Goto(blk14, {v13 -> v14})
blk3:
Statements:
(v15: core::integer::u8) <- 2
End:
Goto(blk14, {v15 -> v14})
blk4:
Statements:
(v16: core::integer::u8) <- 3
End:
Goto(blk14, {v16 -> v14})
blk5:
Statements:
(v17: core::integer::u8) <- 4
End:
Goto(blk14, {v17 -> v14})
blk6:
Statements:
(v18: core::integer::u8) <- 5
End:
Goto(blk14, {v18 -> v14})
blk7:
Statements:
(v19: core::integer::u8) <- 6
End:
Goto(blk14, {v19 -> v14})
blk8:
Statements:
(v20: core::integer::u8) <- 7
End:
Goto(blk14, {v20 -> v14})
blk9:
Statements:
(v21: core::integer::u8) <- 8
End:
Goto(blk14, {v21 -> v14})
blk10:
Statements:
(v22: core::integer::u8) <- 9
End:
Goto(blk14, {v22 -> v14})
blk11:
Statements:
(v23: core::integer::u8) <- 10
End:
Goto(blk14, {v23 -> v14})
blk12:
Statements:
(v24: core::integer::u8) <- 11
End:
Goto(blk14, {v24 -> v14})
blk13:
Statements:
(v25: core::integer::u8) <- 12
End:
Goto(blk14, {v25 -> v14})
blk14:
Statements:
End:
Return(v14)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Propagate over match value.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> u8 {
match 5 {
0 => 1,
1 => 2,
2 => 3,
3 => 4,
4 => 5,
5 => 6,
6 => 7,
7 => 8,
8 => 9,
9 => 10,
10 => 11,
_ => 12,
}
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 5
End:
Match(match core::internal::bounded_int::downcast::<core::felt252, core::internal::bounded_int::BoundedInt::<0, 10>>(v0) {
Option::Some(v1) => blk1,
Option::None => blk13,
})
blk1:
Statements:
End:
Match(match_enum.(v1) {
0(v2) => blk2,
1(v3) => blk3,
2(v4) => blk4,
3(v5) => blk5,
4(v6) => blk6,
5(v7) => blk7,
6(v8) => blk8,
7(v9) => blk9,
8(v10) => blk10,
9(v11) => blk11,
10(v12) => blk12,
})
blk2:
Statements:
(v13: core::integer::u8) <- 1
End:
Goto(blk14, {v13 -> v14})
blk3:
Statements:
(v15: core::integer::u8) <- 2
End:
Goto(blk14, {v15 -> v14})
blk4:
Statements:
(v16: core::integer::u8) <- 3
End:
Goto(blk14, {v16 -> v14})
blk5:
Statements:
(v17: core::integer::u8) <- 4
End:
Goto(blk14, {v17 -> v14})
blk6:
Statements:
(v18: core::integer::u8) <- 5
End:
Goto(blk14, {v18 -> v14})
blk7:
Statements:
(v19: core::integer::u8) <- 6
End:
Goto(blk14, {v19 -> v14})
blk8:
Statements:
(v20: core::integer::u8) <- 7
End:
Goto(blk14, {v20 -> v14})
blk9:
Statements:
(v21: core::integer::u8) <- 8
End:
Goto(blk14, {v21 -> v14})
blk10:
Statements:
(v22: core::integer::u8) <- 9
End:
Goto(blk14, {v22 -> v14})
blk11:
Statements:
(v23: core::integer::u8) <- 10
End:
Goto(blk14, {v23 -> v14})
blk12:
Statements:
(v24: core::integer::u8) <- 11
End:
Goto(blk14, {v24 -> v14})
blk13:
Statements:
(v25: core::integer::u8) <- 12
End:
Goto(blk14, {v25 -> v14})
blk14:
Statements:
End:
Return(v14)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 5
(v1: core::internal::bounded_int::BoundedInt::<0, 10>) <- 5
End:
Goto(blk1, {})
blk1:
Statements:
(v7: ()) <- struct_construct()
End:
Goto(blk7, {})
blk2:
Statements:
(v13: core::integer::u8) <- 1
End:
Goto(blk14, {v13 -> v14})
blk3:
Statements:
(v15: core::integer::u8) <- 2
End:
Goto(blk14, {v15 -> v14})
blk4:
Statements:
(v16: core::integer::u8) <- 3
End:
Goto(blk14, {v16 -> v14})
blk5:
Statements:
(v17: core::integer::u8) <- 4
End:
Goto(blk14, {v17 -> v14})
blk6:
Statements:
(v18: core::integer::u8) <- 5
End:
Goto(blk14, {v18 -> v14})
blk7:
Statements:
(v19: core::integer::u8) <- 6
End:
Goto(blk14, {v19 -> v14})
blk8:
Statements:
(v20: core::integer::u8) <- 7
End:
Goto(blk14, {v20 -> v14})
blk9:
Statements:
(v21: core::integer::u8) <- 8
End:
Goto(blk14, {v21 -> v14})
blk10:
Statements:
(v22: core::integer::u8) <- 9
End:
Goto(blk14, {v22 -> v14})
blk11:
Statements:
(v23: core::integer::u8) <- 10
End:
Goto(blk14, {v23 -> v14})
blk12:
Statements:
(v24: core::integer::u8) <- 11
End:
Goto(blk14, {v24 -> v14})
blk13:
Statements:
(v25: core::integer::u8) <- 12
End:
Goto(blk14, {v25 -> v14})
blk14:
Statements:
End:
Return(v14)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array get at known index of known array - in range.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<Box<@u8>> {
array![0, 1, 2].get(1)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v1: core::integer::u8) <- 0
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v0, v1)
(v3: core::integer::u8) <- 1
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v3)
(v5: core::integer::u8) <- 2
(v6: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v4, v5)
(v7: core::array::Array::<core::integer::u8>, v8: @core::array::Array::<core::integer::u8>) <- snapshot(v6)
(v9: core::integer::u32) <- 1
End:
Match(match core::array::array_get::<core::integer::u8>(v8, v9) {
Option::Some(v10) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v11: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v10)
End:
Goto(blk3, {v11 -> v12})
blk2:
Statements:
(v13: ()) <- struct_construct()
(v14: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v13)
End:
Goto(blk3, {v14 -> v12})
blk3:
Statements:
End:
Return(v12)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v1: core::integer::u8) <- 0
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v0, v1)
(v3: core::integer::u8) <- 1
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v3)
(v5: core::integer::u8) <- 2
(v6: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v4, v5)
(v7: core::array::Array::<core::integer::u8>, v8: @core::array::Array::<core::integer::u8>) <- snapshot(v6)
(v9: core::integer::u32) <- 1
(v15: core::box::Box::<core::integer::u8>) <- 1.into_box()
(v16: core::box::Box::<core::integer::u8>, v17: @core::box::Box::<core::integer::u8>) <- snapshot(v15)
(v10: core::box::Box::<@core::integer::u8>) <- core::box::box_forward_snapshot::<core::integer::u8>(v17)
End:
Goto(blk1, {})
blk1:
Statements:
(v11: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v10)
End:
Goto(blk3, {v11 -> v12})
blk2:
Statements:
(v13: ()) <- struct_construct()
(v14: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v13)
End:
Goto(blk3, {v14 -> v12})
blk3:
Statements:
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array get at known index of known array - out of range.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<Box<@u8>> {
array![0, 1, 2].get(5)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v1: core::integer::u8) <- 0
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v0, v1)
(v3: core::integer::u8) <- 1
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v3)
(v5: core::integer::u8) <- 2
(v6: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v4, v5)
(v7: core::array::Array::<core::integer::u8>, v8: @core::array::Array::<core::integer::u8>) <- snapshot(v6)
(v9: core::integer::u32) <- 5
End:
Match(match core::array::array_get::<core::integer::u8>(v8, v9) {
Option::Some(v10) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v11: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v10)
End:
Goto(blk3, {v11 -> v12})
blk2:
Statements:
(v13: ()) <- struct_construct()
(v14: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v13)
End:
Goto(blk3, {v14 -> v12})
blk3:
Statements:
End:
Return(v12)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v1: core::integer::u8) <- 0
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v0, v1)
(v3: core::integer::u8) <- 1
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v3)
(v5: core::integer::u8) <- 2
(v6: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v4, v5)
(v7: core::array::Array::<core::integer::u8>, v8: @core::array::Array::<core::integer::u8>) <- snapshot(v6)
(v9: core::integer::u32) <- 5
End:
Goto(blk2, {})
blk1:
Statements:
(v11: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v10)
End:
Goto(blk3, {v11 -> v12})
blk2:
Statements:
(v13: ()) <- struct_construct()
(v14: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v13)
End:
Goto(blk3, {v14 -> v12})
blk3:
Statements:
End:
Return(v12)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array get at known index of known size array - in range.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(v: u8) -> Option<Box<@u8>> {
array![v, v, v].get(1)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v1, v0)
(v3: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v0)
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v3, v0)
(v5: core::array::Array::<core::integer::u8>, v6: @core::array::Array::<core::integer::u8>) <- snapshot(v4)
(v7: core::integer::u32) <- 1
End:
Match(match core::array::array_get::<core::integer::u8>(v6, v7) {
Option::Some(v8) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v9: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v1, v0)
(v3: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v0)
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v3, v0)
(v5: core::array::Array::<core::integer::u8>, v6: @core::array::Array::<core::integer::u8>) <- snapshot(v4)
(v7: core::integer::u32) <- 1
End:
Match(match core::array::array_get::<core::integer::u8>(v6, v7) {
Option::Some(v8) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v9: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array get at known index of known size array - out of range.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(v: u8) -> Option<Box<@u8>> {
array![v, v, v].get(5)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v1, v0)
(v3: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v0)
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v3, v0)
(v5: core::array::Array::<core::integer::u8>, v6: @core::array::Array::<core::integer::u8>) <- snapshot(v4)
(v7: core::integer::u32) <- 5
End:
Match(match core::array::array_get::<core::integer::u8>(v6, v7) {
Option::Some(v8) => blk1,
Option::None => blk2,
})
blk1:
Statements:
(v9: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > after
Parameters: v0: core::integer::u8
blk0 (root):
Statements:
(v1: core::array::Array::<core::integer::u8>) <- core::array::array_new::<core::integer::u8>()
(v2: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v1, v0)
(v3: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v2, v0)
(v4: core::array::Array::<core::integer::u8>) <- core::array::array_append::<core::integer::u8>(v3, v0)
(v5: core::array::Array::<core::integer::u8>, v6: @core::array::Array::<core::integer::u8>) <- snapshot(v4)
(v7: core::integer::u32) <- 5
End:
Goto(blk2, {})
blk1:
Statements:
(v9: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::Some(v8)
End:
Goto(blk3, {v9 -> v10})
blk2:
Statements:
(v11: ()) <- struct_construct()
(v12: core::option::Option::<core::box::Box::<@core::integer::u8>>) <- Option::None(v11)
End:
Goto(blk3, {v12 -> v10})
blk3:
Statements:
End:
Return(v10)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array len of known array.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(x: felt252) -> usize {
array![x, x].len()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v2: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v1, v0)
(v3: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v2, v0)
(v4: core::array::Array::<core::felt252>, v5: @core::array::Array::<core::felt252>) <- snapshot(v3)
(v6: core::integer::u32) <- core::array::array_len::<core::felt252>(v5)
End:
Return(v6)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v2: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v1, v0)
(v3: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v2, v0)
(v4: core::array::Array::<core::felt252>, v5: @core::array::Array::<core::felt252>) <- snapshot(v3)
(v6: core::integer::u32) <- 2
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array pop_front known empty array.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<felt252> {
let mut arr = array![];
arr.pop_front()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
End:
Match(match core::array::array_pop_front::<core::felt252>(v0) {
Option::Some(v1, v2) => blk1,
Option::None(v3) => blk2,
})
blk1:
Statements:
(v4: core::felt252) <- unbox(v2)
(v5: core::option::Option::<core::felt252>) <- Option::Some(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::option::Option::<core::felt252>) <- Option::None(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
End:
Goto(blk2, {v0 -> v3})
blk1:
Statements:
(v4: core::felt252) <- unbox(v2)
(v5: core::option::Option::<core::felt252>) <- Option::Some(v4)
End:
Goto(blk3, {v5 -> v6})
blk2:
Statements:
(v7: ()) <- struct_construct()
(v8: core::option::Option::<core::felt252>) <- Option::None(v7)
End:
Goto(blk3, {v8 -> v6})
blk3:
Statements:
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Array pop_front known non-empty array.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<felt252> {
let mut arr = array![1];
arr.pop_front()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::felt252) <- 1
(v2: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v0, v1)
End:
Match(match core::array::array_pop_front::<core::felt252>(v2) {
Option::Some(v3, v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: core::felt252) <- unbox(v4)
(v7: core::option::Option::<core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::felt252) <- 1
(v2: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v0, v1)
End:
Match(match core::array::array_pop_front::<core::felt252>(v2) {
Option::Some(v3, v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: core::felt252) <- 1
(v7: core::option::Option::<core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Span pop_front known empty.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<@felt252> {
let mut span = array![].span();
span.pop_front()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::array::Array::<core::felt252>, v2: @core::array::Array::<core::felt252>) <- snapshot(v0)
End:
Match(match core::array::array_snapshot_pop_front::<core::felt252>(v2) {
Option::Some(v3, v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: @core::felt252) <- unbox(v4)
(v7: core::option::Option::<@core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<@core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::array::Array::<core::felt252>, v2: @core::array::Array::<core::felt252>) <- snapshot(v0)
End:
Goto(blk2, {v2 -> v5})
blk1:
Statements:
(v6: @core::felt252) <- unbox(v4)
(v7: core::option::Option::<@core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<@core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Span pop_back known empty.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> Option<@felt252> {
let mut span = array![].span();
span.pop_back()
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::array::Array::<core::felt252>, v2: @core::array::Array::<core::felt252>) <- snapshot(v0)
End:
Match(match core::array::array_snapshot_pop_back::<core::felt252>(v2) {
Option::Some(v3, v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: @core::felt252) <- unbox(v4)
(v7: core::option::Option::<@core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<@core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v1: core::array::Array::<core::felt252>, v2: @core::array::Array::<core::felt252>) <- snapshot(v0)
End:
Goto(blk2, {v2 -> v5})
blk1:
Statements:
(v6: @core::felt252) <- unbox(v4)
(v7: core::option::Option::<@core::felt252>) <- Option::Some(v6)
End:
Goto(blk3, {v7 -> v8})
blk2:
Statements:
(v9: ()) <- struct_construct()
(v10: core::option::Option::<@core::felt252>) <- Option::None(v9)
End:
Goto(blk3, {v10 -> v8})
blk3:
Statements:
End:
Return(v8)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Panic with byte array value.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() {
core::panics::panic_with_byte_array(@"hello world");
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
(v1: core::felt252) <- 126207244316550804821666916
(v2: core::internal::bounded_int::BoundedInt::<0, 30>) <- 11
(v3: core::byte_array::ByteArray) <- struct_construct(v0, v1, v2)
(v4: core::byte_array::ByteArray, v5: @core::byte_array::ByteArray) <- snapshot(v3)
(v6: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panics::panic_with_byte_array(v5)
(v7: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v6)
End:
Return(v7)
//! > after
Parameters:
blk0 (root):
Statements:
(v8: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
(v9: core::felt252) <- 1997209042069643135709344952807065910992472029923670688473712229447419591075
(v10: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v8, v9)
(v11: core::felt252) <- 0
(v12: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v10, v11)
(v13: core::felt252) <- 126207244316550804821666916
(v14: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v12, v13)
(v15: core::felt252) <- 11
(v16: core::array::Array::<core::felt252>) <- core::array::array_append::<core::felt252>(v14, v15)
(v17: core::panics::Panic) <- struct_construct()
(v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
(v1: core::felt252) <- 126207244316550804821666916
(v2: core::internal::bounded_int::BoundedInt::<0, 30>) <- 11
(v3: core::byte_array::ByteArray) <- struct_construct(v0, v1, v2)
(v4: core::byte_array::ByteArray, v5: @core::byte_array::ByteArray) <- snapshot(v3)
(v6: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v17, v16)
(v7: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v6)
End:
Return(v7)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Match enum on snapshot of enum.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
let v = @Some(1);
match v {
Some(v) => *v,
None => 0,
}
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::option::Option::<core::felt252>, v3: @core::option::Option::<core::felt252>) <- snapshot(v1)
End:
Match(match_enum(v3) {
Option::Some(v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v6 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::option::Option::<core::felt252>, v3: @core::option::Option::<core::felt252>) <- snapshot(v1)
(v9: core::felt252) <- 1
(v10: core::felt252, v4: @core::felt252) <- snapshot(v9)
End:
Goto(blk1, {})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v6 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Match enum with known variant on snapshot of value.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
let v = Some(@1);
match v {
Some(v) => *v,
None => 0,
}
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252, v2: @core::felt252) <- snapshot(v0)
(v3: core::option::Option::<@core::felt252>) <- Option::Some(v2)
End:
Match(match_enum(v3) {
Option::Some(v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v6 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252, v2: @core::felt252) <- snapshot(v0)
(v3: core::option::Option::<@core::felt252>) <- Option::Some(v2)
(v9: @core::felt252) <- 1
(v10: @core::felt252, v4: @core::felt252) <- snapshot(v9)
End:
Goto(blk1, {})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v6 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Match enum on known variant enum.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(a: felt252) -> felt252 {
let v = Some(a);
match v {
Some(v) => v,
None => 0,
}
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
End:
Match(match_enum(v1) {
Option::Some(v2) => blk1,
Option::None(v3) => blk2,
})
blk1:
Statements:
End:
Goto(blk3, {v2 -> v4})
blk2:
Statements:
(v5: core::felt252) <- 0
End:
Goto(blk3, {v5 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
End:
Goto(blk1, {})
blk1:
Statements:
End:
Goto(blk3, {v0 -> v4})
blk2:
Statements:
(v5: core::felt252) <- 0
End:
Goto(blk3, {v5 -> v4})
blk3:
Statements:
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Match enum on snapshot of known variant enum.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(a: felt252) -> felt252 {
let v = @Some(a);
match v {
Some(v) => *v,
None => 0,
}
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::option::Option::<core::felt252>, v3: @core::option::Option::<core::felt252>) <- snapshot(v1)
End:
Match(match_enum(v3) {
Option::Some(v4) => blk1,
Option::None(v5) => blk2,
})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v6 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::option::Option::<core::felt252>) <- Option::Some(v0)
(v2: core::option::Option::<core::felt252>, v3: @core::option::Option::<core::felt252>) <- snapshot(v1)
(v9: core::felt252, v4: @core::felt252) <- snapshot(v0)
End:
Goto(blk1, {})
blk1:
Statements:
(v6: core::felt252) <- desnap(v4)
End:
Goto(blk3, {v0 -> v7})
blk2:
Statements:
(v8: core::felt252) <- 0
End:
Goto(blk3, {v8 -> v7})
blk3:
Statements:
End:
Return(v7)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 add const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
1 + 2
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252) <- 2
(v2: core::felt252) <- core::felt252_add(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252) <- 2
(v2: core::felt252) <- 3
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 sub const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
5 - 3
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 5
(v1: core::felt252) <- 3
(v2: core::felt252) <- core::felt252_sub(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 5
(v1: core::felt252) <- 3
(v2: core::felt252) <- 2
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 mul const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
2 * 3
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::felt252) <- 3
(v2: core::felt252) <- core::felt252_mul(v0, v1)
End:
Return(v2)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 2
(v1: core::felt252) <- 3
(v2: core::felt252) <- 6
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 combined operations const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
1 + 2 * 3 - 4
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252) <- 2
(v2: core::felt252) <- 3
(v3: core::felt252) <- core::felt252_mul(v1, v2)
(v4: core::felt252) <- core::felt252_add(v0, v3)
(v5: core::felt252) <- 4
(v6: core::felt252) <- core::felt252_sub(v4, v5)
End:
Return(v6)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 1
(v1: core::felt252) <- 2
(v2: core::felt252) <- 3
(v3: core::felt252) <- 6
(v4: core::felt252) <- 7
(v5: core::felt252) <- 4
(v6: core::felt252) <- 3
End:
Return(v6)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 div const fold.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
let x = core::felt252_div(6, 30);
x * 5
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 6
(v1: core::zeroable::NonZero::<core::felt252>) <- NonZero(30)
(v2: core::felt252) <- core::felt252_div(v0, v1)
(v3: core::felt252) <- 5
(v4: core::felt252) <- core::felt252_mul(v2, v3)
End:
Return(v4)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::felt252) <- 6
(v1: core::zeroable::NonZero::<core::felt252>) <- NonZero(30)
(v2: core::felt252) <- 2894802230932904970957858226476056084498485772265277359978473644908697616385
(v3: core::felt252) <- 5
(v4: core::felt252) <- 1
End:
Return(v4)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 div by one.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(a: felt252) -> felt252 {
core::felt252_div(a, 1)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::zeroable::NonZero::<core::felt252>) <- NonZero(1)
(v2: core::felt252) <- core::felt252_div(v0, v1)
End:
Return(v2)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::zeroable::NonZero::<core::felt252>) <- NonZero(1)
(v2: core::felt252) <- core::felt252_div(v0, v1)
End:
Return(v0)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Felt252 zero div.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo(a: NonZero<felt252>) -> felt252 {
core::felt252_div(0, a)
}
//! > function_name
foo
//! > semantic_diagnostics
//! > before
Parameters: v0: core::zeroable::NonZero::<core::felt252>
blk0 (root):
Statements:
(v1: core::felt252) <- 0
(v2: core::felt252) <- core::felt252_div(v1, v0)
End:
Return(v2)
//! > after
Parameters: v0: core::zeroable::NonZero::<core::felt252>
blk0 (root):
Statements:
(v1: core::felt252) <- 0
(v2: core::felt252) <- 0
End:
Return(v2)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Bounded int trim_min on non-min.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
match trim_min(0_i8) {
core::internal::OptionRev::Some(x) => upcast(x),
core::internal::OptionRev::None => 200,
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
use core::internal::bounded_int::{trim_min, upcast};
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 0
End:
Match(match core::internal::bounded_int::bounded_int_trim_min::<core::integer::i8, core::internal::bounded_int::trim_impl::Min::<core::integer::i8, -127, 127>>(v0) {
OptionRev::None => blk1,
OptionRev::Some(v1) => blk2,
})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 127>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 0
(v1: core::internal::bounded_int::BoundedInt::<-127, 127>) <- 0
End:
Goto(blk2, {})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- 0
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Bounded int trim_min on min.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
match trim_min(-0x80_i8) {
core::internal::OptionRev::Some(x) => upcast(x),
core::internal::OptionRev::None => 200,
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
use core::internal::bounded_int::{trim_min, upcast};
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -128
End:
Match(match core::internal::bounded_int::bounded_int_trim_min::<core::integer::i8, core::internal::bounded_int::trim_impl::Min::<core::integer::i8, -127, 127>>(v0) {
OptionRev::None => blk1,
OptionRev::Some(v1) => blk2,
})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 127>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- -128
End:
Goto(blk1, {})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-127, 127>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Bounded int trim_max on non-max.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
match trim_max(0_i8) {
core::internal::OptionRev::Some(x) => upcast(x),
core::internal::OptionRev::None => 200,
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
use core::internal::bounded_int::{trim_max, upcast};
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 0
End:
Match(match core::internal::bounded_int::bounded_int_trim_max::<core::integer::i8, core::internal::bounded_int::trim_impl::Max::<core::integer::i8, -128, 126>>(v0) {
OptionRev::None => blk1,
OptionRev::Some(v1) => blk2,
})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 126>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 0
(v1: core::internal::bounded_int::BoundedInt::<-128, 126>) <- 0
End:
Goto(blk2, {})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- 0
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > lowering_diagnostics
//! > ==========================================================================
//! > Bounded int trim_max on max.
//! > test_runner_name
test_match_optimizer
//! > function_code
fn foo() -> felt252 {
match trim_max(0x7f_i8) {
core::internal::OptionRev::Some(x) => upcast(x),
core::internal::OptionRev::None => 200,
}
}
//! > function_name
foo
//! > module_code
#[feature("bounded-int-utils")]
use core::internal::bounded_int::{trim_max, upcast};
//! > semantic_diagnostics
//! > before
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 127
End:
Match(match core::internal::bounded_int::bounded_int_trim_max::<core::integer::i8, core::internal::bounded_int::trim_impl::Max::<core::integer::i8, -128, 126>>(v0) {
OptionRev::None => blk1,
OptionRev::Some(v1) => blk2,
})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 126>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > after
Parameters:
blk0 (root):
Statements:
(v0: core::integer::i8) <- 127
End:
Goto(blk1, {})
blk1:
Statements:
(v2: core::felt252) <- 200
End:
Goto(blk3, {v2 -> v3})
blk2:
Statements:
(v4: core::felt252) <- core::internal::bounded_int::upcast::<core::internal::bounded_int::BoundedInt::<-128, 126>, core::felt252>(v1)
End:
Goto(blk3, {v4 -> v3})
blk3:
Statements:
End:
Return(v3)
//! > lowering_diagnostics