//! > Test implicits with multiple jumps to arm blocks.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(a: u256) -> u64 {
    U256TryIntoU64::try_into(a).unwrap()
}

//! > function_name
foo

//! > module_code
impl U256TryIntoU64 of TryInto<u256, u64> {
    #[inline(always)]
    fn try_into(self: u256) -> Option<u64> {
        if (self.high == 0) {
            self.low.try_into()
        } else {
            None
        }
    }
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::RangeCheck, v1: core::integer::u256
blk0 (root):
Statements:
  (v2: core::integer::u128, v3: core::integer::u128) <- struct_destructure(v1)
End:
  Match(match core::integer::u128_is_zero(v3) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v4) => blk4,
  })

blk1:
Statements:
End:
  Match(match core::internal::bounded_int::downcast::<core::integer::u128, core::integer::u64>(v0, v2) {
    Option::Some(v5, v6) => blk2,
    Option::None(v7) => blk3,
  })

blk2:
Statements:
  (v8: (core::integer::u64,)) <- struct_construct(v6)
  (v9: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Ok(v8)
End:
  Return(v5, v9)

blk3:
Statements:
End:
  Goto(blk5, {v7 -> v10})

blk4:
Statements:
End:
  Goto(blk5, {v0 -> v10})

blk5:
Statements:
  (v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<29721761890975875353235833581453094220424382983267374>()
  (v12: core::panics::PanicResult::<(core::integer::u64,)>) <- PanicResult::Err(v11)
End:
  Return(v10, v12)

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::felt252) <- 5u
  (v2: core::felt252, v1: core::bool) <- foo[expr14](v0)
End:
  Return(v1)


Generated:
Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: core::felt252) <- 1u
  (v2: core::felt252) <- core::Felt252Add::add(v0, v1)
  (v3: core::felt252) <- 10u
  (v4: core::felt252) <- core::Felt252Sub::sub(v2, v3)
End:
  Match(match core::felt252_is_zero(v4) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v7) => blk2,
  })

blk1:
Statements:
  (v5: ()) <- struct_construct()
  (v6: core::bool) <- bool::True(v5)
End:
  Return(v2, v6)

blk2:
Statements:
End:
  Goto(blk3, {})

blk3:
Statements:
  (v9: core::felt252, v8: core::bool) <- foo[expr14](v2)
End:
  Return(v9, v8)

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

//! > Not adding ignored implicits.

//! > test_runner_name
test_function_lowering(expect_diagnostics: false)

//! > function_code
fn foo(x: u128) -> u128 {
    if false {
        x + 1
    } else {
        x
    }
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: core::integer::u128
blk0 (root):
Statements:
  (v1: (core::integer::u128,)) <- struct_construct(v0)
  (v2: core::panics::PanicResult::<(core::integer::u128,)>) <- PanicResult::Ok(v1)
End:
  Return(v2)
