//! > Test loop.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> bool {
    let mut x = 5;
    loop {
        let y = x + 1;
        x = y;
        if y == 10 {
            break true;
        };
    }
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

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


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-149]{5, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v8: core::felt252, v9: core::bool) <- struct_destructure(v5)
  (v10: (core::bool,)) <- struct_construct(v9)
  (v11: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Ok(v10)
End:
  Return(v2, v7, v11)

blk2:
Statements:
  (v12: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v12)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: core::felt252) <- 1
  (v2: core::felt252) <- core::Felt252Add::add(v0, v1)
  (v3: core::felt252, v4: @core::felt252) <- snapshot(v2)
  (v5: core::felt252) <- 10
  (v6: core::felt252, v7: @core::felt252) <- snapshot(v5)
  (v8: core::bool) <- core::Felt252PartialEq::eq(v4, v7)
End:
  Match(match_enum(v8) {
    bool::False(v10) => blk2,
    bool::True(v9) => blk1,
  })

blk1:
Statements:
  (v11: ()) <- struct_construct()
  (v12: core::bool) <- bool::True(v11)
End:
  Return(v2, v12)

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

blk3:
Statements:
  (v14: core::felt252, v13: core::bool) <- test::foo[38-149](v2)
End:
  Return(v14, v13)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk4,
  })

blk1:
Statements:
  (v7: core::felt252) <- 1
  (v8: core::felt252) <- core::felt252_add(v2, v7)
  (v9: core::felt252) <- 10
  (v10: core::felt252) <- core::felt252_sub(v8, v9)
End:
  Match(match core::felt252_is_zero(v10) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v13: ()) <- struct_construct()
  (v14: core::bool) <- bool::True(v13)
  (v15: (core::felt252, core::bool)) <- struct_construct(v8, v14)
  (v16: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Ok(v15)
End:
  Return(v3, v12, v16)

blk3:
Statements:
  (v17: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v18: core::RangeCheck, v19: core::gas::GasBuiltin, v20: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-149](v3, v17, v8)
End:
  Return(v18, v19, v20)

blk4:
Statements:
  (v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v22: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v21)
End:
  Return(v5, v6, v22)


Final lowering of specialized call "test::foo[38-149]{5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk2,
  })

blk1:
Statements:
  (v6: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v7: core::felt252) <- 6
  (v8: core::RangeCheck, v9: core::gas::GasBuiltin, v10: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-149](v2, v6, v7)
End:
  Return(v8, v9, v10)

blk2:
Statements:
  (v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v12: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v11)
End:
  Return(v4, v5, v12)

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

//! > Test loop with duplicate member path.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> bool {
    let mut x = 5;
    loop {
        x = x + 1;
        if x == 10 {
            break true;
        };
    }
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

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


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-130]{5, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v8: core::felt252, v9: core::bool) <- struct_destructure(v5)
  (v10: (core::bool,)) <- struct_construct(v9)
  (v11: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Ok(v10)
End:
  Return(v2, v7, v11)

blk2:
Statements:
  (v12: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v12)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: core::felt252) <- 1
  (v2: core::felt252) <- core::Felt252Add::add(v0, v1)
  (v3: core::felt252, v4: @core::felt252) <- snapshot(v2)
  (v5: core::felt252) <- 10
  (v6: core::felt252, v7: @core::felt252) <- snapshot(v5)
  (v8: core::bool) <- core::Felt252PartialEq::eq(v4, v7)
End:
  Match(match_enum(v8) {
    bool::False(v10) => blk2,
    bool::True(v9) => blk1,
  })

blk1:
Statements:
  (v11: ()) <- struct_construct()
  (v12: core::bool) <- bool::True(v11)
End:
  Return(v3, v12)

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

blk3:
Statements:
  (v14: core::felt252, v13: core::bool) <- test::foo[38-130](v3)
End:
  Return(v14, v13)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk4,
  })

blk1:
Statements:
  (v7: core::felt252) <- 1
  (v8: core::felt252) <- core::felt252_add(v2, v7)
  (v9: core::felt252) <- 10
  (v10: core::felt252) <- core::felt252_sub(v8, v9)
End:
  Match(match core::felt252_is_zero(v10) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v13: ()) <- struct_construct()
  (v14: core::bool) <- bool::True(v13)
  (v15: (core::felt252, core::bool)) <- struct_construct(v8, v14)
  (v16: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Ok(v15)
End:
  Return(v3, v12, v16)

blk3:
Statements:
  (v17: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v18: core::RangeCheck, v19: core::gas::GasBuiltin, v20: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-130](v3, v17, v8)
End:
  Return(v18, v19, v20)

blk4:
Statements:
  (v21: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v22: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v21)
End:
  Return(v5, v6, v22)


Final lowering of specialized call "test::foo[38-130]{5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk2,
  })

blk1:
Statements:
  (v6: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v7: core::felt252) <- 6
  (v8: core::RangeCheck, v9: core::gas::GasBuiltin, v10: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-130](v2, v6, v7)
End:
  Return(v8, v9, v10)

blk2:
Statements:
  (v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v12: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v11)
End:
  Return(v4, v5, v12)

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

//! > Test loop with member path borrowing.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(mut a: A, ref b: A) {
    let c = 5_usize;
    loop {
        let mut h = 0;
        a.b.c = c;
        if true {
            h = 1;
            let mut x = 4;
            x = 5;
            b = A { b: a.b, x };
            break b;
        };
    };
}

//! > function_name
foo

//! > module_code
#[derive(Copy, Drop)]
struct A {
    b: B,
    x: felt252,
}
#[derive(Copy, Drop)]
struct B {
    c: usize,
    y: u128,
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters: v0: test::A, v1: test::A
blk0 (root):
Statements:
  (v2: core::integer::u32) <- 5
  (v3: test::B, v4: core::felt252) <- struct_destructure(v0)
  (v6: core::integer::u32, v7: test::A, v5: test::A) <- test::foo[50-256](v2, v1, v3)
  (v8: core::integer::u32, v9: core::integer::u128) <- struct_destructure(v3)
  (v10: ()) <- struct_construct()
End:
  Return(v7, v10)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: test::A, v3: test::A
blk0 (root):
Statements:
  (v4: core::integer::u32) <- 5
  (v5: test::B, v6: core::felt252) <- struct_destructure(v2)
  (v7: core::RangeCheck, v8: core::gas::GasBuiltin, v9: core::panics::PanicResult::<(core::integer::u32, test::A, test::A)>) <- test::foo[50-256](v0, v1, v4, v3, v5)
End:
  Match(match_enum(v9) {
    PanicResult::Ok(v10) => blk1,
    PanicResult::Err(v11) => blk2,
  })

blk1:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v8)
  (v13: core::integer::u32, v14: test::A, v15: test::A) <- struct_destructure(v10)
  (v16: ()) <- struct_construct()
  (v17: (test::A, ())) <- struct_construct(v14, v16)
  (v18: core::panics::PanicResult::<(test::A, ())>) <- PanicResult::Ok(v17)
End:
  Return(v7, v12, v18)

blk2:
Statements:
  (v19: core::panics::PanicResult::<(test::A, ())>) <- PanicResult::Err(v11)
End:
  Return(v7, v8, v19)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     };
|_____^

Parameters: v0: core::integer::u32, v1: test::A, v2: test::B
blk0 (root):
Statements:
  (v3: core::felt252) <- 0
  (v4: core::integer::u32, v5: core::integer::u128) <- struct_destructure(v2)
  (v6: ()) <- struct_construct()
  (v7: core::bool) <- bool::True(v6)
End:
  Match(match_enum(v7) {
    bool::False(v9) => blk2,
    bool::True(v8) => blk1,
  })

blk1:
Statements:
  (v10: core::felt252) <- 1
  (v11: core::felt252) <- 4
  (v12: core::felt252) <- 5
  (v13: test::B) <- struct_construct(v0, v5)
  (v14: test::A) <- struct_construct(v13, v12)
  (v15: core::integer::u32, v16: core::integer::u128) <- struct_destructure(v13)
End:
  Return(v15, v14, v14)

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

blk3:
Statements:
  (v17: test::B) <- struct_construct(v0, v5)
  (v19: core::integer::u32, v20: test::A, v18: test::A) <- test::foo[50-256](v0, v1, v17)
  (v21: core::integer::u32, v22: core::integer::u128) <- struct_destructure(v17)
End:
  Return(v19, v20, v18)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::integer::u32, v3: test::A, v4: test::B
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v5, v6) => blk1,
    Option::None(v7, v8) => blk2,
  })

blk1:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v6)
  (v10: core::integer::u32, v11: core::integer::u128) <- struct_destructure(v4)
  (v12: core::felt252) <- 5
  (v13: test::B) <- struct_construct(v2, v11)
  (v14: test::A) <- struct_construct(v13, v12)
  (v15: (core::integer::u32, test::A, test::A)) <- struct_construct(v2, v14, v14)
  (v16: core::panics::PanicResult::<(core::integer::u32, test::A, test::A)>) <- PanicResult::Ok(v15)
End:
  Return(v5, v9, v16)

blk2:
Statements:
  (v17: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v18: core::panics::PanicResult::<(core::integer::u32, test::A, test::A)>) <- PanicResult::Err(v17)
End:
  Return(v7, v8, v18)


Final lowering of specialized call "test::foo[50-256]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::integer::u32, v3: test::A, v4: test::B
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v5, v6) => blk1,
    Option::None(v7, v8) => blk2,
  })

blk1:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v6)
  (v10: core::integer::u32, v11: core::integer::u128) <- struct_destructure(v4)
  (v12: core::felt252) <- 5
  (v13: test::B) <- struct_construct(v2, v11)
  (v14: test::A) <- struct_construct(v13, v12)
  (v15: (core::integer::u32, test::A, test::A)) <- struct_construct(v2, v14, v14)
  (v16: core::panics::PanicResult::<(core::integer::u32, test::A, test::A)>) <- PanicResult::Ok(v15)
End:
  Return(v5, v9, v16)

blk2:
Statements:
  (v17: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v18: core::panics::PanicResult::<(core::integer::u32, test::A, test::A)>) <- PanicResult::Err(v17)
End:
  Return(v7, v8, v18)

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

//! > Test loop with continue.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> bool {
    let mut x = 5;
    loop {
        let y = x + 1;
        x = y;
        if y == 7 {
            continue;
        }
        if y == 10 {
            break true;
        };
    }
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

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


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-201]{5, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v8: core::felt252, v9: core::bool) <- struct_destructure(v5)
  (v10: (core::bool,)) <- struct_construct(v9)
  (v11: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Ok(v10)
End:
  Return(v2, v7, v11)

blk2:
Statements:
  (v12: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v12)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: core::felt252) <- 1
  (v2: core::felt252) <- core::Felt252Add::add(v0, v1)
  (v3: core::felt252, v4: @core::felt252) <- snapshot(v2)
  (v5: core::felt252) <- 7
  (v6: core::felt252, v7: @core::felt252) <- snapshot(v5)
  (v8: core::bool) <- core::Felt252PartialEq::eq(v4, v7)
End:
  Match(match_enum(v8) {
    bool::False(v10) => blk2,
    bool::True(v9) => blk1,
  })

blk1:
Statements:
  (v12: core::felt252, v11: core::bool) <- test::foo[38-201](v2)
End:
  Return(v12, v11)

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

blk3:
Statements:
  (v13: core::felt252, v14: @core::felt252) <- snapshot(v3)
  (v15: core::felt252) <- 10
  (v16: core::felt252, v17: @core::felt252) <- snapshot(v15)
  (v18: core::bool) <- core::Felt252PartialEq::eq(v14, v17)
End:
  Match(match_enum(v18) {
    bool::False(v20) => blk5,
    bool::True(v19) => blk4,
  })

blk4:
Statements:
  (v21: ()) <- struct_construct()
  (v22: core::bool) <- bool::True(v21)
End:
  Return(v2, v22)

blk5:
Statements:
End:
  Goto(blk6, {})

blk6:
Statements:
  (v24: core::felt252, v23: core::bool) <- test::foo[38-201](v2)
End:
  Return(v24, v23)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk7,
  })

blk1:
Statements:
  (v7: core::felt252) <- 1
  (v8: core::felt252) <- core::felt252_add(v2, v7)
  (v9: core::felt252) <- 7
  (v10: core::felt252) <- core::felt252_sub(v8, v9)
End:
  Match(match core::felt252_is_zero(v10) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
End:
  Goto(blk6, {v12 -> v13})

blk3:
Statements:
  (v14: core::felt252) <- 10
  (v15: core::felt252) <- core::felt252_sub(v8, v14)
End:
  Match(match core::felt252_is_zero(v15) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v16) => blk5,
  })

blk4:
Statements:
  (v17: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v18: ()) <- struct_construct()
  (v19: core::bool) <- bool::True(v18)
  (v20: (core::felt252, core::bool)) <- struct_construct(v8, v19)
  (v21: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Ok(v20)
End:
  Return(v3, v17, v21)

blk5:
Statements:
  (v22: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
End:
  Goto(blk6, {v22 -> v13})

blk6:
Statements:
  (v23: core::RangeCheck, v24: core::gas::GasBuiltin, v25: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-201](v3, v13, v8)
End:
  Return(v23, v24, v25)

blk7:
Statements:
  (v26: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v27: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v26)
End:
  Return(v5, v6, v27)


Final lowering of specialized call "test::foo[38-201]{5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk2,
  })

blk1:
Statements:
  (v6: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v7: core::felt252) <- 6
  (v8: core::RangeCheck, v9: core::gas::GasBuiltin, v10: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[38-201](v2, v6, v7)
End:
  Return(v8, v9, v10)

blk2:
Statements:
  (v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v12: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v11)
End:
  Return(v4, v5, v12)

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

//! > Test loop with break;

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    loop {
        break;
    }
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: ()) <- test::foo[11-43]()
End:
  Return(v0)


Final lowering:
Parameters:
blk0 (root):
Statements:
End:
  Return()


Generated loop lowering for source location:
      loop {
 _____^
|         break;
|     }
|_____^

Parameters:
blk0 (root):
Statements:
  (v0: ()) <- struct_construct()
End:
  Return(v0)


Final lowering:
Parameters:
blk0 (root):
Statements:
End:
  Return()

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

//! > Change in block merge in loop.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    let mut x = A { a: 3, b: 4 };
    loop {
        if (true) {
            x.a = 0;
        } else {
            x.a = 0;
        }

        if x.a == 0 {
            break;
        };
    };
}

//! > function_name
foo

//! > module_code
#[derive(Copy, Drop, Debug)]
struct A {
    a: u8,
    b: u8,
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u8) <- 3
  (v1: core::integer::u8) <- 4
  (v2: test::A) <- struct_construct(v0, v1)
  (v3: core::integer::u8, v4: core::integer::u8) <- struct_destructure(v2)
  (v6: core::integer::u8, v5: ()) <- test::foo[45-203](v3)
  (v7: ()) <- struct_construct()
End:
  Return(v7)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::integer::u8) <- 3
  (v3: core::RangeCheck, v4: core::gas::GasBuiltin, v5: core::panics::PanicResult::<(core::integer::u8, ())>) <- test::foo[45-203](v0, v1, v2)
End:
  Match(match_enum(v5) {
    PanicResult::Ok(v6) => blk1,
    PanicResult::Err(v7) => blk2,
  })

blk1:
Statements:
  (v8: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v9: ()) <- struct_construct()
  (v10: ((),)) <- struct_construct(v9)
  (v11: core::panics::PanicResult::<((),)>) <- PanicResult::Ok(v10)
End:
  Return(v3, v8, v11)

blk2:
Statements:
  (v12: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v7)
End:
  Return(v3, v4, v12)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     };
|_____^

Parameters: v0: core::integer::u8
blk0 (root):
Statements:
  (v1: ()) <- struct_construct()
  (v2: core::bool) <- bool::True(v1)
End:
  Match(match_enum(v2) {
    bool::False(v4) => blk2,
    bool::True(v3) => blk1,
  })

blk1:
Statements:
  (v6: core::integer::u8) <- 0
End:
  Goto(blk3, {v6 -> v7})

blk2:
Statements:
  (v5: core::integer::u8) <- 0
End:
  Goto(blk3, {v5 -> v7})

blk3:
Statements:
  (v8: core::integer::u8, v9: @core::integer::u8) <- snapshot(v7)
  (v10: core::integer::u8) <- 0
  (v11: core::integer::u8, v12: @core::integer::u8) <- snapshot(v10)
  (v13: core::bool) <- core::integer::U8PartialEq::eq(v9, v12)
End:
  Match(match_enum(v13) {
    bool::False(v15) => blk5,
    bool::True(v14) => blk4,
  })

blk4:
Statements:
  (v16: ()) <- struct_construct()
End:
  Return(v8, v16)

blk5:
Statements:
End:
  Goto(blk6, {})

blk6:
Statements:
  (v18: core::integer::u8, v17: ()) <- test::foo[45-203](v8)
End:
  Return(v18, v17)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::integer::u8
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v8: core::integer::u8) <- 0
  (v9: ()) <- struct_construct()
  (v10: (core::integer::u8, ())) <- struct_construct(v8, v9)
  (v11: core::panics::PanicResult::<(core::integer::u8, ())>) <- PanicResult::Ok(v10)
End:
  Return(v3, v7, v11)

blk2:
Statements:
  (v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v13: core::panics::PanicResult::<(core::integer::u8, ())>) <- PanicResult::Err(v12)
End:
  Return(v5, v6, v13)


Final lowering of specialized call "test::foo[45-203]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::integer::u8
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v8: core::integer::u8) <- 0
  (v9: ()) <- struct_construct()
  (v10: (core::integer::u8, ())) <- struct_construct(v8, v9)
  (v11: core::panics::PanicResult::<(core::integer::u8, ())>) <- PanicResult::Ok(v10)
End:
  Return(v3, v7, v11)

blk2:
Statements:
  (v12: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v13: core::panics::PanicResult::<(core::integer::u8, ())>) <- PanicResult::Err(v12)
End:
  Return(v5, v6, v13)

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

//! > Test snap usage after loop.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> bool {
    let mut s = S {};
    loop {
        s.foo();
        break;
    }
    s.foo();
    false
}

//! > function_name
foo

//! > module_code
#[derive(Drop)]
struct S {}
trait T {
    fn foo(self: @S);
}
impl I of T {
    fn foo(self: @S) {}
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: test::S) <- struct_construct()
  (v1: test::S, v2: @test::S) <- snapshot(v0)
  (v3: ()) <- test::foo[41-90](v2)
  (v4: test::S, v5: @test::S) <- snapshot(v1)
  (v6: ()) <- test::I::foo(v5)
  (v7: ()) <- struct_construct()
  (v8: core::bool) <- bool::False(v7)
End:
  Return(v8)


Final lowering:
Parameters:
blk0 (root):
Statements:
  (v0: ()) <- struct_construct()
  (v1: core::bool) <- bool::False(v0)
End:
  Return(v1)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: @test::S
blk0 (root):
Statements:
  (v1: ()) <- test::I::foo(v0)
  (v2: ()) <- struct_construct()
End:
  Return(v2)


Final lowering:
Parameters: v0: @test::S
blk0 (root):
Statements:
End:
  Return()

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

//! > Test snap usage after loop of member.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    let t = T { s: S {} };
    loop {
        TT::f1oo(@t.s);
        break;
    }
    TT::f1oo(@t.s);
}

//! > function_name
foo

//! > module_code
#[derive(Drop)]
struct S {}
#[derive(Drop)]
struct T {
    s: S,
}
trait TT {
    fn f1oo(self: @S);
}
impl STT of TT {
    fn f1oo(self: @S) {}
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: test::S) <- struct_construct()
  (v1: test::T) <- struct_construct(v0)
  (v2: test::S) <- struct_destructure(v1)
  (v3: test::S, v4: @test::S) <- snapshot(v2)
  (v5: ()) <- test::foo[38-94](v4)
  (v6: test::S, v7: @test::S) <- snapshot(v3)
  (v8: ()) <- test::STT::f1oo(v7)
  (v9: ()) <- struct_construct()
End:
  Return(v9)


Final lowering:
Parameters:
blk0 (root):
Statements:
End:
  Return()


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: @test::S
blk0 (root):
Statements:
  (v1: ()) <- test::STT::f1oo(v0)
  (v2: ()) <- struct_construct()
End:
  Return(v2)


Final lowering:
Parameters: v0: @test::S
blk0 (root):
Statements:
End:
  Return()

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

//! > Test real usage of inner with snap usage of outer.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    let a = A { b: B { c: 3 } };
    loop {
        let _x = @a.b;
        ex1(_x);
        loop {
            let _y = a.b.c;
            ex(_y);
            break;
        }
        break;
    };
}

//! > function_name
foo

//! > module_code
extern fn ex(a: u32) nopanic;
extern fn ex1(a: @B) nopanic;
#[derive(Drop)]
struct B {
    c: u32,
}
#[derive(Drop)]
struct A {
    b: B,
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u32) <- 3
  (v1: test::B) <- struct_construct(v0)
  (v2: test::A) <- struct_construct(v1)
  (v3: test::B) <- struct_destructure(v2)
  (v4: core::integer::u32) <- struct_destructure(v3)
  (v5: test::B) <- struct_construct(v4)
  (v6: test::B, v7: @test::B) <- snapshot(v5)
  (v8: ()) <- test::foo[44-207](v4, v7)
  (v9: ()) <- struct_construct()
End:
  Return(v9)


Final lowering:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u32) <- 3
  (v1: test::B) <- struct_construct(v0)
  (v2: test::B, v3: @test::B) <- snapshot(v1)
  () <- test::ex1(v3)
  () <- test::ex(v0)
End:
  Return()


Generated loop lowering for source location:
          loop {
 _________^
| ...
|         }
|_________^

Parameters: v0: core::integer::u32
blk0 (root):
Statements:
  () <- test::ex(v0)
  (v1: ()) <- struct_construct()
End:
  Return(v1)


Final lowering:
Parameters: v0: core::integer::u32
blk0 (root):
Statements:
  () <- test::ex(v0)
End:
  Return()


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     };
|_____^

Parameters: v0: core::integer::u32, v1: @test::B
blk0 (root):
Statements:
  () <- test::ex1(v1)
  (v2: ()) <- test::foo[95-187](v0)
  (v3: ()) <- struct_construct()
End:
  Return(v3)


Final lowering:
Parameters: v0: core::integer::u32, v1: @test::B
blk0 (root):
Statements:
  () <- test::ex1(v1)
  () <- test::ex(v0)
End:
  Return()

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

//! > Test snap usage of inner with real usage of outer.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    let a = A { b: B { c: 3 } };
    loop {
        let _x = a.b;
        ex1(_x);
        loop {
            let _y = @a.b.c;
            ex(_y);
            break;
        }
        break;
    };
}

//! > function_name
foo

//! > module_code
extern fn ex(a: @u32) nopanic;
extern fn ex1(a: B) nopanic;
#[derive(Drop, Copy)]
struct B {
    c: u32,
}
#[derive(Drop)]
struct A {
    b: B,
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u32) <- 3
  (v1: test::B) <- struct_construct(v0)
  (v2: test::A) <- struct_construct(v1)
  (v3: test::B) <- struct_destructure(v2)
  (v4: ()) <- test::foo[44-207](v3)
  (v5: ()) <- struct_construct()
End:
  Return(v5)


Final lowering:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u32) <- 3
  (v1: test::B) <- struct_construct(v0)
  () <- test::ex1(v1)
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v0)
  () <- test::ex(v3)
End:
  Return()


Generated loop lowering for source location:
          loop {
 _________^
| ...
|         }
|_________^

Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  () <- test::ex(v0)
  (v1: ()) <- struct_construct()
End:
  Return(v1)


Final lowering:
Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  () <- test::ex(v0)
End:
  Return()


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     };
|_____^

Parameters: v0: test::B
blk0 (root):
Statements:
  () <- test::ex1(v0)
  (v1: core::integer::u32) <- struct_destructure(v0)
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v1)
  (v4: ()) <- test::foo[94-187](v3)
  (v5: ()) <- struct_construct()
End:
  Return(v5)


Final lowering:
Parameters: v0: test::B
blk0 (root):
Statements:
  () <- test::ex1(v0)
  (v1: core::integer::u32) <- struct_destructure(v0)
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v1)
  () <- test::ex(v3)
End:
  Return()

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

//! > Test change usage of inner with snap usage of outer.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    let mut a = A { x: 0 };
    let mut i = 1;
    while i != 5 {
        a.x = i;
        use_a(@a);
        i += 1;
    };
}

//! > function_name
foo

//! > module_code
#[derive(Drop)]
struct A {
    x: felt252,
}
extern fn use_a(a: @A) nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::felt252) <- 0
  (v1: test::A) <- struct_construct(v0)
  (v2: core::felt252) <- 1
  (v4: test::A, v5: core::felt252, v3: ()) <- test::foo[58-134](v2, v1)
  (v6: ()) <- struct_construct()
End:
  Return(v6)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- test::foo[58-134]{1, { 0 }, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v8: ()) <- struct_construct()
  (v9: ((),)) <- struct_construct(v8)
  (v10: core::panics::PanicResult::<((),)>) <- PanicResult::Ok(v9)
End:
  Return(v2, v7, v10)

blk2:
Statements:
  (v11: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v11)


Generated loop lowering for source location:
      while i != 5 {
 _____^
| ...
|     };
|_____^

Parameters: v0: core::felt252, v1: test::A
blk0 (root):
Statements:
  (v2: core::felt252, v3: @core::felt252) <- snapshot(v0)
  (v4: core::felt252) <- 5
  (v5: core::felt252, v6: @core::felt252) <- snapshot(v4)
  (v7: core::bool) <- core::Felt252PartialEq::ne(v3, v6)
End:
  Match(match_enum(v7) {
    bool::False(v19) => blk2,
    bool::True(v8) => blk1,
  })

blk1:
Statements:
  (v9: core::felt252) <- struct_destructure(v1)
  (v10: test::A) <- struct_construct(v2)
  (v11: test::A, v12: @test::A) <- snapshot(v10)
  () <- test::use_a(v12)
  (v13: core::felt252) <- 1
  (v15: core::felt252, v14: ()) <- core::ops::arith::DeprecatedAddAssign::<core::felt252, core::Felt252AddEq>::add_assign(v2, v13)
  (v17: test::A, v18: core::felt252, v16: ()) <- test::foo[58-134](v15, v11)
End:
  Return(v17, v18, v16)

blk2:
Statements:
  (v20: ()) <- struct_construct()
End:
  Return(v1, v2, v20)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252, v3: test::A
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v4, v5) => blk1,
    Option::None(v6, v7) => blk4,
  })

blk1:
Statements:
  (v8: core::felt252) <- 5
  (v9: core::felt252) <- core::felt252_sub(v2, v8)
End:
  Match(match core::felt252_is_zero(v9) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v10) => blk3,
  })

blk2:
Statements:
  (v11: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v5)
  (v12: ()) <- struct_construct()
  (v13: (test::A, core::felt252, ())) <- struct_construct(v3, v2, v12)
  (v14: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- PanicResult::Ok(v13)
End:
  Return(v4, v11, v14)

blk3:
Statements:
  (v15: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v5)
  (v16: test::A) <- struct_construct(v2)
  (v17: test::A, v18: @test::A) <- snapshot(v16)
  () <- test::use_a(v18)
  (v19: core::felt252) <- 1
  (v20: core::felt252) <- core::felt252_add(v2, v19)
  (v21: core::RangeCheck, v22: core::gas::GasBuiltin, v23: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- test::foo[58-134](v4, v15, v20, v17)
End:
  Return(v21, v22, v23)

blk4:
Statements:
  (v24: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v25: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- PanicResult::Err(v24)
End:
  Return(v6, v7, v25)


Final lowering of specialized call "test::foo[58-134]{1, { 0 }, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk2,
  })

blk1:
Statements:
  (v6: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v7: core::felt252) <- 1
  (v8: test::A) <- struct_construct(v7)
  (v9: test::A, v10: @test::A) <- snapshot(v8)
  () <- test::use_a(v10)
  (v11: core::felt252) <- 2
  (v12: core::RangeCheck, v13: core::gas::GasBuiltin, v14: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- test::foo[58-134](v2, v6, v11, v9)
End:
  Return(v12, v13, v14)

blk2:
Statements:
  (v15: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v16: core::panics::PanicResult::<(test::A, core::felt252, ())>) <- PanicResult::Err(v15)
End:
  Return(v4, v5, v16)

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

//! > Test default implementation with loop.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() {
    MyTrait::impl_in_trait();
}

//! > function_name
foo

//! > module_code
trait MyTrait {
    fn impl_in_impl(x: u8) -> bool;
    fn impl_in_trait() -> u8 {
        let mut i = 0;
        loop {
            if Self::impl_in_impl(i) {
                break;
            }
            i += 1;
        }
        i
    }
}

impl MyImpl of MyTrait {
    fn impl_in_impl(x: u8) -> bool {
        x == 30
    }
}

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u8) <- test::MyImpl::impl_in_trait()
  (v1: ()) <- struct_construct()
End:
  Return(v1)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::integer::u8, ())>) <- test::MyImpl::impl_in_trait[54-175]{0, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v8: ()) <- struct_construct()
  (v9: ((),)) <- struct_construct(v8)
  (v10: core::panics::PanicResult::<((),)>) <- PanicResult::Ok(v9)
End:
  Return(v2, v7, v10)

blk2:
Statements:
  (v11: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v11)

//! > lowering_diagnostics

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

//! > Test early return within a loop.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> u32 {
    let mut x = 5;
    loop {
        let y = x + 1;
        x = y;
        if y == 10 {
            break true;
        }

        if y == 5 {
            return 5;
        }

        if y == 3 {
            continue;
        }
    }
    1
}

//! > function_name
foo

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::felt252) <- 5
  (v2: core::felt252, v1: core::internal::LoopResult::<core::bool, core::integer::u32>) <- test::foo[37-253](v0)
End:
  Match(match_enum(v1) {
    LoopResult::Normal(v3) => blk1,
    LoopResult::EarlyReturn(v4) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v3 -> v5})

blk2:
Statements:
End:
  Return(v4)

blk3:
Statements:
  (v6: core::integer::u32) <- 1
End:
  Return(v6)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- test::foo[37-253]{5, }(v0, v1)
End:
  Match(match_enum(v4) {
    PanicResult::Ok(v5) => blk1,
    PanicResult::Err(v6) => blk4,
  })

blk1:
Statements:
  (v7: core::felt252, v8: core::internal::LoopResult::<core::bool, core::integer::u32>) <- struct_destructure(v5)
End:
  Match(match_enum(v8) {
    LoopResult::Normal(v9) => blk2,
    LoopResult::EarlyReturn(v10) => blk3,
  })

blk2:
Statements:
  (v11: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v12: core::integer::u32) <- 1
  (v13: (core::integer::u32,)) <- struct_construct(v12)
  (v14: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v13)
End:
  Return(v2, v11, v14)

blk3:
Statements:
  (v15: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v16: (core::integer::u32,)) <- struct_construct(v10)
  (v17: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v16)
End:
  Return(v2, v15, v17)

blk4:
Statements:
  (v18: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Err(v6)
End:
  Return(v2, v3, v18)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::felt252
blk0 (root):
Statements:
  (v1: core::felt252) <- 1
  (v2: core::felt252) <- core::Felt252Add::add(v0, v1)
  (v3: core::felt252, v4: @core::felt252) <- snapshot(v2)
  (v5: core::felt252) <- 10
  (v6: core::felt252, v7: @core::felt252) <- snapshot(v5)
  (v8: core::bool) <- core::Felt252PartialEq::eq(v4, v7)
End:
  Match(match_enum(v8) {
    bool::False(v10) => blk2,
    bool::True(v9) => blk1,
  })

blk1:
Statements:
  (v11: ()) <- struct_construct()
  (v12: core::bool) <- bool::True(v11)
  (v13: core::internal::LoopResult::<core::bool, core::integer::u32>) <- LoopResult::Normal(v12)
End:
  Return(v2, v13)

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

blk3:
Statements:
  (v14: core::felt252, v15: @core::felt252) <- snapshot(v3)
  (v16: core::felt252) <- 5
  (v17: core::felt252, v18: @core::felt252) <- snapshot(v16)
  (v19: core::bool) <- core::Felt252PartialEq::eq(v15, v18)
End:
  Match(match_enum(v19) {
    bool::False(v21) => blk5,
    bool::True(v20) => blk4,
  })

blk4:
Statements:
  (v22: core::integer::u32) <- 5
  (v23: core::internal::LoopResult::<core::bool, core::integer::u32>) <- LoopResult::EarlyReturn(v22)
End:
  Return(v2, v23)

blk5:
Statements:
End:
  Goto(blk6, {})

blk6:
Statements:
  (v24: core::felt252, v25: @core::felt252) <- snapshot(v14)
  (v26: core::felt252) <- 3
  (v27: core::felt252, v28: @core::felt252) <- snapshot(v26)
  (v29: core::bool) <- core::Felt252PartialEq::eq(v25, v28)
End:
  Match(match_enum(v29) {
    bool::False(v31) => blk8,
    bool::True(v30) => blk7,
  })

blk7:
Statements:
  (v33: core::felt252, v32: core::internal::LoopResult::<core::bool, core::integer::u32>) <- test::foo[37-253](v2)
End:
  Return(v33, v32)

blk8:
Statements:
End:
  Goto(blk9, {})

blk9:
Statements:
  (v35: core::felt252, v34: core::internal::LoopResult::<core::bool, core::integer::u32>) <- test::foo[37-253](v2)
End:
  Return(v35, v34)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk9,
  })

blk1:
Statements:
  (v7: core::felt252) <- 1
  (v8: core::felt252) <- core::felt252_add(v2, v7)
  (v9: core::felt252) <- 10
  (v10: core::felt252) <- core::felt252_sub(v8, v9)
End:
  Match(match core::felt252_is_zero(v10) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v13: ()) <- struct_construct()
  (v14: core::bool) <- bool::True(v13)
  (v15: core::internal::LoopResult::<core::bool, core::integer::u32>) <- LoopResult::Normal(v14)
  (v16: (core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)) <- struct_construct(v8, v15)
  (v17: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- PanicResult::Ok(v16)
End:
  Return(v3, v12, v17)

blk3:
Statements:
  (v18: core::felt252) <- 5
  (v19: core::felt252) <- core::felt252_sub(v8, v18)
End:
  Match(match core::felt252_is_zero(v19) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v20) => blk5,
  })

blk4:
Statements:
  (v21: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v22: core::integer::u32) <- 5
  (v23: core::internal::LoopResult::<core::bool, core::integer::u32>) <- LoopResult::EarlyReturn(v22)
  (v24: (core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)) <- struct_construct(v8, v23)
  (v25: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- PanicResult::Ok(v24)
End:
  Return(v3, v21, v25)

blk5:
Statements:
  (v26: core::felt252) <- 3
  (v27: core::felt252) <- core::felt252_sub(v8, v26)
End:
  Match(match core::felt252_is_zero(v27) {
    IsZeroResult::Zero => blk6,
    IsZeroResult::NonZero(v28) => blk7,
  })

blk6:
Statements:
  (v29: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
End:
  Goto(blk8, {v29 -> v30})

blk7:
Statements:
  (v31: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
End:
  Goto(blk8, {v31 -> v30})

blk8:
Statements:
  (v32: core::RangeCheck, v33: core::gas::GasBuiltin, v34: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- test::foo[37-253](v3, v30, v8)
End:
  Return(v32, v33, v34)

blk9:
Statements:
  (v35: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v36: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- PanicResult::Err(v35)
End:
  Return(v5, v6, v36)


Final lowering of specialized call "test::foo[37-253]{5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk2,
  })

blk1:
Statements:
  (v6: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v7: core::felt252) <- 6
  (v8: core::RangeCheck, v9: core::gas::GasBuiltin, v10: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- test::foo[37-253](v2, v6, v7)
End:
  Return(v8, v9, v10)

blk2:
Statements:
  (v11: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v12: core::panics::PanicResult::<(core::felt252, core::internal::LoopResult::<core::bool, core::integer::u32>)>) <- PanicResult::Err(v11)
End:
  Return(v4, v5, v12)

//! > lowering_diagnostics

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

//! > Test early return within a loop without a normal return.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(a: u32) -> u32 {
    loop {
        if a == 0 {
            break;
        }
        return 5;
    }
    1
}

//! > function_name
foo

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters: v0: core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32, v2: @core::integer::u32) <- snapshot(v0)
  (v3: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[24-108](v2)
End:
  Match(match_enum(v3) {
    LoopResult::Normal(v4) => blk1,
    LoopResult::EarlyReturn(v5) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v4 -> v6})

blk2:
Statements:
End:
  Return(v5)

blk3:
Statements:
  (v7: core::integer::u32) <- 1
End:
  Return(v7)


Final lowering:
Parameters: v0: core::integer::u32
blk0 (root):
Statements:
End:
  Match(match core::integer::u32_is_zero(v0) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v1) => blk2,
  })

blk1:
Statements:
  (v2: core::integer::u32) <- 1
End:
  Return(v2)

blk2:
Statements:
  (v3: core::integer::u32) <- 5
End:
  Return(v3)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- 0
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v1)
  (v4: core::bool) <- core::integer::U32PartialEq::eq(v0, v3)
End:
  Match(match_enum(v4) {
    bool::False(v6) => blk2,
    bool::True(v5) => blk1,
  })

blk1:
Statements:
  (v7: ()) <- struct_construct()
  (v8: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v7)
End:
  Return(v8)

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

blk3:
Statements:
  (v9: core::integer::u32) <- 5
  (v10: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v9)
End:
  Return(v10)


Final lowering:
Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- desnap(v0)
End:
  Match(match core::integer::u32_is_zero(v1) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v2) => blk2,
  })

blk1:
Statements:
  (v3: ()) <- struct_construct()
  (v4: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v3)
End:
  Return(v4)

blk2:
Statements:
  (v5: core::integer::u32) <- 5
  (v6: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v5)
End:
  Return(v6)

//! > lowering_diagnostics

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

//! > Test nested loop where the inner loop has no normal return.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(mut a: Array<u32>) -> u32 {
    while let Some(v) = a.pop_front() {
        if v == 1 {
            continue;
        }

        loop {
            if v == 0 {
                break;
            }

            return 5;
        }

        return 6;
    }
    7
}

//! > function_name
foo

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters: v0: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v2: core::array::Array::<core::integer::u32>, v1: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[35-262](v0)
End:
  Match(match_enum(v1) {
    LoopResult::Normal(v3) => blk1,
    LoopResult::EarlyReturn(v4) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v3 -> v5})

blk2:
Statements:
End:
  Return(v4)

blk3:
Statements:
  (v6: core::integer::u32) <- 7
End:
  Return(v6)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v3: core::RangeCheck, v4: core::gas::GasBuiltin, v5: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v0, v1, v2)
End:
  Match(match_enum(v5) {
    PanicResult::Ok(v6) => blk1,
    PanicResult::Err(v7) => blk4,
  })

blk1:
Statements:
  (v8: core::array::Array::<core::integer::u32>, v9: core::internal::LoopResult::<(), core::integer::u32>) <- struct_destructure(v6)
End:
  Match(match_enum(v9) {
    LoopResult::Normal(v10) => blk2,
    LoopResult::EarlyReturn(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v13: core::integer::u32) <- 7
  (v14: (core::integer::u32,)) <- struct_construct(v13)
  (v15: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v14)
End:
  Return(v3, v12, v15)

blk3:
Statements:
  (v16: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v17: (core::integer::u32,)) <- struct_construct(v11)
  (v18: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v17)
End:
  Return(v3, v16, v18)

blk4:
Statements:
  (v19: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Err(v7)
End:
  Return(v3, v4, v19)


Generated loop lowering for source location:
          loop {
 _________^
| ...
|         }
|_________^

Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- 0
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v1)
  (v4: core::bool) <- core::integer::U32PartialEq::eq(v0, v3)
End:
  Match(match_enum(v4) {
    bool::False(v6) => blk2,
    bool::True(v5) => blk1,
  })

blk1:
Statements:
  (v7: ()) <- struct_construct()
  (v8: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v7)
End:
  Return(v8)

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

blk3:
Statements:
  (v9: core::integer::u32) <- 5
  (v10: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v9)
End:
  Return(v10)


Final lowering:
Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- desnap(v0)
End:
  Match(match core::integer::u32_is_zero(v1) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v2) => blk2,
  })

blk1:
Statements:
  (v3: ()) <- struct_construct()
  (v4: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v3)
End:
  Return(v4)

blk2:
Statements:
  (v5: core::integer::u32) <- 5
  (v6: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v5)
End:
  Return(v6)


Generated loop lowering for source location:
      while let Some(v) = a.pop_front() {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v2: core::array::Array::<core::integer::u32>, v1: core::option::Option::<core::integer::u32>) <- core::array::ArrayImpl::<core::integer::u32>::pop_front(v0)
End:
  Match(match_enum(v1) {
    Option::Some(v3) => blk1,
    Option::None(v4) => blk2,
  })

blk1:
Statements:
  (v5: core::integer::u32, v6: @core::integer::u32) <- snapshot(v3)
  (v7: core::integer::u32) <- 1
  (v8: core::integer::u32, v9: @core::integer::u32) <- snapshot(v7)
  (v10: core::bool) <- core::integer::U32PartialEq::eq(v6, v9)
End:
  Match(match_enum(v10) {
    bool::False(v12) => blk4,
    bool::True(v11) => blk3,
  })

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

blk3:
Statements:
  (v14: core::array::Array::<core::integer::u32>, v13: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[35-262](v2)
End:
  Return(v14, v13)

blk4:
Statements:
End:
  Goto(blk5, {})

blk5:
Statements:
  (v15: core::integer::u32, v16: @core::integer::u32) <- snapshot(v5)
  (v17: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[127-237](v16)
End:
  Match(match_enum(v17) {
    LoopResult::Normal(v18) => blk6,
    LoopResult::EarlyReturn(v19) => blk7,
  })

blk6:
Statements:
End:
  Goto(blk8, {v18 -> v21})

blk7:
Statements:
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
End:
  Return(v2, v20)

blk8:
Statements:
  (v22: core::integer::u32) <- 6
  (v23: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v22)
End:
  Return(v2, v23)

blk9:
Statements:
  (v24: ()) <- struct_construct()
  (v25: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v24)
End:
  Return(v2, v25)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk8,
  })

blk1:
Statements:
End:
  Match(match core::array::array_pop_front::<core::integer::u32>(v2) {
    Option::Some(v7, v8) => blk2,
    Option::None(v9) => blk7,
  })

blk2:
Statements:
  (v10: core::integer::u32) <- unbox(v8)
  (v11: core::integer::u32) <- 1
End:
  Match(match core::integer::u32_eq(v10, v11) {
    bool::False => blk3,
    bool::True => blk6,
  })

blk3:
Statements:
End:
  Match(match core::integer::u32_is_zero(v10) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v12) => blk5,
  })

blk4:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v14: core::integer::u32) <- 6
  (v15: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v14)
  (v16: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v15)
  (v17: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v16)
End:
  Return(v3, v13, v17)

blk5:
Statements:
  (v18: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v19: core::integer::u32) <- 5
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
  (v21: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v20)
  (v22: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v21)
End:
  Return(v3, v18, v22)

blk6:
Statements:
  (v23: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v24: core::RangeCheck, v25: core::gas::GasBuiltin, v26: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v3, v23, v7)
End:
  Return(v24, v25, v26)

blk7:
Statements:
  (v27: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v28: ()) <- struct_construct()
  (v29: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v28)
  (v30: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v9, v29)
  (v31: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v30)
End:
  Return(v3, v27, v31)

blk8:
Statements:
  (v32: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v33: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Err(v32)
End:
  Return(v5, v6, v33)


Final lowering of specialized call "test::foo[35-262]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk8,
  })

blk1:
Statements:
End:
  Match(match core::array::array_pop_front::<core::integer::u32>(v2) {
    Option::Some(v7, v8) => blk2,
    Option::None(v9) => blk7,
  })

blk2:
Statements:
  (v10: core::integer::u32) <- unbox(v8)
  (v11: core::integer::u32) <- 1
End:
  Match(match core::integer::u32_eq(v10, v11) {
    bool::False => blk3,
    bool::True => blk6,
  })

blk3:
Statements:
End:
  Match(match core::integer::u32_is_zero(v10) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v12) => blk5,
  })

blk4:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v14: core::integer::u32) <- 6
  (v15: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v14)
  (v16: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v15)
  (v17: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v16)
End:
  Return(v3, v13, v17)

blk5:
Statements:
  (v18: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v19: core::integer::u32) <- 5
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
  (v21: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v20)
  (v22: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v21)
End:
  Return(v3, v18, v22)

blk6:
Statements:
  (v23: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v24: core::RangeCheck, v25: core::gas::GasBuiltin, v26: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v3, v23, v7)
End:
  Return(v24, v25, v26)

blk7:
Statements:
  (v27: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v28: ()) <- struct_construct()
  (v29: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v28)
  (v30: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v9, v29)
  (v31: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v30)
End:
  Return(v3, v27, v31)

blk8:
Statements:
  (v32: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v33: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Err(v32)
End:
  Return(v5, v6, v33)

//! > lowering_diagnostics

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

//! > Test nested loop where the inner loop has an early return.

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(mut a: Array<u32>) -> u32 {
    while let Some(v) = a.pop_front() {
        if v == 1 {
            continue;
        }

        loop {
            if v == 0 {
                break;
            }

            return 5;
        }

        return 6;
    }
    7
}

//! > function_name
foo

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters: v0: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v2: core::array::Array::<core::integer::u32>, v1: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[35-262](v0)
End:
  Match(match_enum(v1) {
    LoopResult::Normal(v3) => blk1,
    LoopResult::EarlyReturn(v4) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v3 -> v5})

blk2:
Statements:
End:
  Return(v4)

blk3:
Statements:
  (v6: core::integer::u32) <- 7
End:
  Return(v6)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v3: core::RangeCheck, v4: core::gas::GasBuiltin, v5: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v0, v1, v2)
End:
  Match(match_enum(v5) {
    PanicResult::Ok(v6) => blk1,
    PanicResult::Err(v7) => blk4,
  })

blk1:
Statements:
  (v8: core::array::Array::<core::integer::u32>, v9: core::internal::LoopResult::<(), core::integer::u32>) <- struct_destructure(v6)
End:
  Match(match_enum(v9) {
    LoopResult::Normal(v10) => blk2,
    LoopResult::EarlyReturn(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v13: core::integer::u32) <- 7
  (v14: (core::integer::u32,)) <- struct_construct(v13)
  (v15: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v14)
End:
  Return(v3, v12, v15)

blk3:
Statements:
  (v16: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v17: (core::integer::u32,)) <- struct_construct(v11)
  (v18: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Ok(v17)
End:
  Return(v3, v16, v18)

blk4:
Statements:
  (v19: core::panics::PanicResult::<(core::integer::u32,)>) <- PanicResult::Err(v7)
End:
  Return(v3, v4, v19)


Generated loop lowering for source location:
          loop {
 _________^
| ...
|         }
|_________^

Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- 0
  (v2: core::integer::u32, v3: @core::integer::u32) <- snapshot(v1)
  (v4: core::bool) <- core::integer::U32PartialEq::eq(v0, v3)
End:
  Match(match_enum(v4) {
    bool::False(v6) => blk2,
    bool::True(v5) => blk1,
  })

blk1:
Statements:
  (v7: ()) <- struct_construct()
  (v8: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v7)
End:
  Return(v8)

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

blk3:
Statements:
  (v9: core::integer::u32) <- 5
  (v10: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v9)
End:
  Return(v10)


Final lowering:
Parameters: v0: @core::integer::u32
blk0 (root):
Statements:
  (v1: core::integer::u32) <- desnap(v0)
End:
  Match(match core::integer::u32_is_zero(v1) {
    IsZeroResult::Zero => blk1,
    IsZeroResult::NonZero(v2) => blk2,
  })

blk1:
Statements:
  (v3: ()) <- struct_construct()
  (v4: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v3)
End:
  Return(v4)

blk2:
Statements:
  (v5: core::integer::u32) <- 5
  (v6: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v5)
End:
  Return(v6)


Generated loop lowering for source location:
      while let Some(v) = a.pop_front() {
 _____^
| ...
|     }
|_____^

Parameters: v0: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
  (v2: core::array::Array::<core::integer::u32>, v1: core::option::Option::<core::integer::u32>) <- core::array::ArrayImpl::<core::integer::u32>::pop_front(v0)
End:
  Match(match_enum(v1) {
    Option::Some(v3) => blk1,
    Option::None(v4) => blk2,
  })

blk1:
Statements:
  (v5: core::integer::u32, v6: @core::integer::u32) <- snapshot(v3)
  (v7: core::integer::u32) <- 1
  (v8: core::integer::u32, v9: @core::integer::u32) <- snapshot(v7)
  (v10: core::bool) <- core::integer::U32PartialEq::eq(v6, v9)
End:
  Match(match_enum(v10) {
    bool::False(v12) => blk4,
    bool::True(v11) => blk3,
  })

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

blk3:
Statements:
  (v14: core::array::Array::<core::integer::u32>, v13: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[35-262](v2)
End:
  Return(v14, v13)

blk4:
Statements:
End:
  Goto(blk5, {})

blk5:
Statements:
  (v15: core::integer::u32, v16: @core::integer::u32) <- snapshot(v5)
  (v17: core::internal::LoopResult::<(), core::integer::u32>) <- test::foo[127-237](v16)
End:
  Match(match_enum(v17) {
    LoopResult::Normal(v18) => blk6,
    LoopResult::EarlyReturn(v19) => blk7,
  })

blk6:
Statements:
End:
  Goto(blk8, {v18 -> v21})

blk7:
Statements:
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
End:
  Return(v2, v20)

blk8:
Statements:
  (v22: core::integer::u32) <- 6
  (v23: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v22)
End:
  Return(v2, v23)

blk9:
Statements:
  (v24: ()) <- struct_construct()
  (v25: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v24)
End:
  Return(v2, v25)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk8,
  })

blk1:
Statements:
End:
  Match(match core::array::array_pop_front::<core::integer::u32>(v2) {
    Option::Some(v7, v8) => blk2,
    Option::None(v9) => blk7,
  })

blk2:
Statements:
  (v10: core::integer::u32) <- unbox(v8)
  (v11: core::integer::u32) <- 1
End:
  Match(match core::integer::u32_eq(v10, v11) {
    bool::False => blk3,
    bool::True => blk6,
  })

blk3:
Statements:
End:
  Match(match core::integer::u32_is_zero(v10) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v12) => blk5,
  })

blk4:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v14: core::integer::u32) <- 6
  (v15: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v14)
  (v16: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v15)
  (v17: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v16)
End:
  Return(v3, v13, v17)

blk5:
Statements:
  (v18: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v19: core::integer::u32) <- 5
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
  (v21: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v20)
  (v22: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v21)
End:
  Return(v3, v18, v22)

blk6:
Statements:
  (v23: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v24: core::RangeCheck, v25: core::gas::GasBuiltin, v26: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v3, v23, v7)
End:
  Return(v24, v25, v26)

blk7:
Statements:
  (v27: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v28: ()) <- struct_construct()
  (v29: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v28)
  (v30: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v9, v29)
  (v31: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v30)
End:
  Return(v3, v27, v31)

blk8:
Statements:
  (v32: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v33: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Err(v32)
End:
  Return(v5, v6, v33)


Final lowering of specialized call "test::foo[35-262]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::array::Array::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk8,
  })

blk1:
Statements:
End:
  Match(match core::array::array_pop_front::<core::integer::u32>(v2) {
    Option::Some(v7, v8) => blk2,
    Option::None(v9) => blk7,
  })

blk2:
Statements:
  (v10: core::integer::u32) <- unbox(v8)
  (v11: core::integer::u32) <- 1
End:
  Match(match core::integer::u32_eq(v10, v11) {
    bool::False => blk3,
    bool::True => blk6,
  })

blk3:
Statements:
End:
  Match(match core::integer::u32_is_zero(v10) {
    IsZeroResult::Zero => blk4,
    IsZeroResult::NonZero(v12) => blk5,
  })

blk4:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v14: core::integer::u32) <- 6
  (v15: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v14)
  (v16: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v15)
  (v17: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v16)
End:
  Return(v3, v13, v17)

blk5:
Statements:
  (v18: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v19: core::integer::u32) <- 5
  (v20: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::EarlyReturn(v19)
  (v21: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v7, v20)
  (v22: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v21)
End:
  Return(v3, v18, v22)

blk6:
Statements:
  (v23: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v24: core::RangeCheck, v25: core::gas::GasBuiltin, v26: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- test::foo[35-262](v3, v23, v7)
End:
  Return(v24, v25, v26)

blk7:
Statements:
  (v27: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v28: ()) <- struct_construct()
  (v29: core::internal::LoopResult::<(), core::integer::u32>) <- LoopResult::Normal(v28)
  (v30: (core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)) <- struct_construct(v9, v29)
  (v31: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Ok(v30)
End:
  Return(v3, v27, v31)

blk8:
Statements:
  (v32: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v33: core::panics::PanicResult::<(core::array::Array::<core::integer::u32>, core::internal::LoopResult::<(), core::integer::u32>)>) <- PanicResult::Err(v32)
End:
  Return(v5, v6, v33)

//! > lowering_diagnostics

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

//! > Test error propagation inside a for loop

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> Result<(), u32> {
    for _ in 1..5_u32 {
        bar()?;
    }
    Ok(())
}

//! > function_name
foo

//! > module_code
extern fn bar() -> Result<(), u32> nopanic;

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::integer::u32) <- 1
  (v1: core::integer::u32) <- 5
  (v2: core::ops::range::Range::<core::integer::u32>) <- core::ops::range::RangeOpImpl::<core::integer::u32>::range(v0, v1)
  (v3: core::ops::range::internal::IntRange::<core::integer::u32>) <- core::ops::range::SierraRangeIntoIterator::<core::integer::u32, core::integer::u32Copy, core::integer::u32Drop, core::ops::range::SierraIntRangeSupportU32>::into_iter(v2)
  (v5: core::ops::range::internal::IntRange::<core::integer::u32>, v4: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- test::foo[30-76](v3)
End:
  Match(match_enum(v4) {
    LoopResult::Normal(v6) => blk1,
    LoopResult::EarlyReturn(v7) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v6 -> v8})

blk2:
Statements:
End:
  Return(v7)

blk3:
Statements:
  (v9: ()) <- struct_construct()
  (v10: core::result::Result::<(), core::integer::u32>) <- Result::Ok(v9)
End:
  Return(v10)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::integer::u32) <- 1
  (v3: core::integer::u32) <- 5
End:
  Match(match core::ops::range::internal::int_range_try_new::<core::integer::u32>(v0, v2, v3) {
    Result::Ok(v4, v5) => blk1,
    Result::Err(v6, v7) => blk2,
  })

blk1:
Statements:
  (v8: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v1)
End:
  Goto(blk3, {v4 -> v9, v8 -> v10, v5 -> v11})

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v1)
End:
  Goto(blk3, {v6 -> v9, v12 -> v10, v7 -> v11})

blk3:
Statements:
  (v13: core::RangeCheck, v14: core::gas::GasBuiltin, v15: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- test::foo[30-76](v9, v10, v11)
End:
  Match(match_enum(v15) {
    PanicResult::Ok(v16) => blk4,
    PanicResult::Err(v17) => blk7,
  })

blk4:
Statements:
  (v18: core::ops::range::internal::IntRange::<core::integer::u32>, v19: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- struct_destructure(v16)
End:
  Match(match_enum(v19) {
    LoopResult::Normal(v20) => blk5,
    LoopResult::EarlyReturn(v21) => blk6,
  })

blk5:
Statements:
  (v22: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v14)
  (v23: ()) <- struct_construct()
  (v24: core::result::Result::<(), core::integer::u32>) <- Result::Ok(v23)
  (v25: (core::result::Result::<(), core::integer::u32>,)) <- struct_construct(v24)
  (v26: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Ok(v25)
End:
  Return(v13, v22, v26)

blk6:
Statements:
  (v27: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v14)
  (v28: (core::result::Result::<(), core::integer::u32>,)) <- struct_construct(v21)
  (v29: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Ok(v28)
End:
  Return(v13, v27, v29)

blk7:
Statements:
  (v30: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Err(v17)
End:
  Return(v13, v14, v30)


Generated loop lowering for source location:
      for _ in 1..5_u32 {
 _____^
|         bar()?;
|     }
|_____^

Parameters: v0: core::ops::range::internal::IntRange::<core::integer::u32>
blk0 (root):
Statements:
  (v2: core::ops::range::internal::IntRange::<core::integer::u32>, v1: core::option::Option::<core::integer::u32>) <- core::ops::range::internal::IntRangeIteratorImpl::<core::integer::u32, core::integer::u32Copy, core::integer::u32Drop>::next(v0)
End:
  Match(match_enum(v1) {
    Option::Some(v3) => blk1,
    Option::None(v11) => blk5,
  })

blk1:
Statements:
End:
  Match(match test::bar() {
    Result::Ok => blk2,
    Result::Err(v5) => blk3,
  })

blk2:
Statements:
  (v4: ()) <- struct_construct()
End:
  Goto(blk4, {v4 -> v8})

blk3:
Statements:
  (v6: core::result::Result::<(), core::integer::u32>) <- Result::Err(v5)
  (v7: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::EarlyReturn(v6)
End:
  Return(v2, v7)

blk4:
Statements:
  (v10: core::ops::range::internal::IntRange::<core::integer::u32>, v9: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- test::foo[30-76](v2)
End:
  Return(v10, v9)

blk5:
Statements:
  (v12: ()) <- struct_construct()
  (v13: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::Normal(v12)
End:
  Return(v2, v13)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::ops::range::internal::IntRange::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk6,
  })

blk1:
Statements:
End:
  Match(match core::ops::range::internal::int_range_pop_front::<core::integer::u32>(v2) {
    OptionRev::None => blk2,
    OptionRev::Some(v7, v8) => blk3,
  })

blk2:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v10: ()) <- struct_construct()
  (v11: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::Normal(v10)
  (v12: (core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)) <- struct_construct(v2, v11)
  (v13: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Ok(v12)
End:
  Return(v3, v9, v13)

blk3:
Statements:
End:
  Match(match test::bar() {
    Result::Ok => blk4,
    Result::Err(v14) => blk5,
  })

blk4:
Statements:
  (v15: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v16: core::RangeCheck, v17: core::gas::GasBuiltin, v18: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- test::foo[30-76](v3, v15, v7)
End:
  Return(v16, v17, v18)

blk5:
Statements:
  (v19: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v20: core::result::Result::<(), core::integer::u32>) <- Result::Err(v14)
  (v21: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::EarlyReturn(v20)
  (v22: (core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)) <- struct_construct(v7, v21)
  (v23: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Ok(v22)
End:
  Return(v3, v19, v23)

blk6:
Statements:
  (v24: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v25: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Err(v24)
End:
  Return(v5, v6, v25)


Final lowering of specialized call "test::foo[30-76]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::ops::range::internal::IntRange::<core::integer::u32>
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk6,
  })

blk1:
Statements:
End:
  Match(match core::ops::range::internal::int_range_pop_front::<core::integer::u32>(v2) {
    OptionRev::None => blk2,
    OptionRev::Some(v7, v8) => blk3,
  })

blk2:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v10: ()) <- struct_construct()
  (v11: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::Normal(v10)
  (v12: (core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)) <- struct_construct(v2, v11)
  (v13: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Ok(v12)
End:
  Return(v3, v9, v13)

blk3:
Statements:
End:
  Match(match test::bar() {
    Result::Ok => blk4,
    Result::Err(v14) => blk5,
  })

blk4:
Statements:
  (v15: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v16: core::RangeCheck, v17: core::gas::GasBuiltin, v18: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- test::foo[30-76](v3, v15, v7)
End:
  Return(v16, v17, v18)

blk5:
Statements:
  (v19: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v20: core::result::Result::<(), core::integer::u32>) <- Result::Err(v14)
  (v21: core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>) <- LoopResult::EarlyReturn(v20)
  (v22: (core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)) <- struct_construct(v7, v21)
  (v23: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Ok(v22)
End:
  Return(v3, v19, v23)

blk6:
Statements:
  (v24: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v25: core::panics::PanicResult::<(core::ops::range::internal::IntRange::<core::integer::u32>, core::internal::LoopResult::<(), core::result::Result::<(), core::integer::u32>>)>) <- PanicResult::Err(v24)
End:
  Return(v5, v6, v25)

//! > lowering_diagnostics

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

//! > Test error propagation inside a loop (no normal return)

//! > test_runner_name
test_generated_function

//! > function_code
fn foo() -> Result<(), u32> {
    loop {
        bar()?;
    }
}

//! > function_name
foo

//! > module_code
#[inline(never)]
fn bar() -> Result<(), u32> {
    Ok(())
}

//! > expected_diagnostics

//! > semantic_diagnostics

//! > lowering
Main:
Parameters:
blk0 (root):
Statements:
  (v0: core::result::Result::<(), core::integer::u32>) <- test::foo[30-63]()
End:
  Return(v0)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v2: core::RangeCheck, v3: core::gas::GasBuiltin, v4: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- test::foo[30-63](v0, v1)
End:
  Return(v2, v3, v4)


Generated loop lowering for source location:
      loop {
 _____^
|         bar()?;
|     }
|_____^

Parameters:
blk0 (root):
Statements:
  (v0: core::result::Result::<(), core::integer::u32>) <- test::bar()
End:
  Match(match_enum(v0) {
    Result::Ok(v1) => blk1,
    Result::Err(v2) => blk2,
  })

blk1:
Statements:
End:
  Goto(blk3, {v1 -> v4})

blk2:
Statements:
  (v3: core::result::Result::<(), core::integer::u32>) <- Result::Err(v2)
End:
  Return(v3)

blk3:
Statements:
  (v5: core::result::Result::<(), core::integer::u32>) <- test::foo[30-63]()
End:
  Return(v5)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk4,
  })

blk1:
Statements:
  (v6: core::result::Result::<(), core::integer::u32>) <- test::bar()
End:
  Match(match_enum(v6) {
    Result::Ok(v7) => blk2,
    Result::Err(v8) => blk3,
  })

blk2:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v10: core::RangeCheck, v11: core::gas::GasBuiltin, v12: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- test::foo[30-63](v2, v9)
End:
  Return(v10, v11, v12)

blk3:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v14: core::result::Result::<(), core::integer::u32>) <- Result::Err(v8)
  (v15: (core::result::Result::<(), core::integer::u32>,)) <- struct_construct(v14)
  (v16: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Ok(v15)
End:
  Return(v2, v13, v16)

blk4:
Statements:
  (v17: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v18: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Err(v17)
End:
  Return(v4, v5, v18)


Final lowering of specialized call "test::foo[30-63]":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v2, v3) => blk1,
    Option::None(v4, v5) => blk4,
  })

blk1:
Statements:
  (v6: core::result::Result::<(), core::integer::u32>) <- test::bar()
End:
  Match(match_enum(v6) {
    Result::Ok(v7) => blk2,
    Result::Err(v8) => blk3,
  })

blk2:
Statements:
  (v9: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v10: core::RangeCheck, v11: core::gas::GasBuiltin, v12: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- test::foo[30-63](v2, v9)
End:
  Return(v10, v11, v12)

blk3:
Statements:
  (v13: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v3)
  (v14: core::result::Result::<(), core::integer::u32>) <- Result::Err(v8)
  (v15: (core::result::Result::<(), core::integer::u32>,)) <- struct_construct(v14)
  (v16: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Ok(v15)
End:
  Return(v2, v13, v16)

blk4:
Statements:
  (v17: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v18: core::panics::PanicResult::<(core::result::Result::<(), core::integer::u32>,)>) <- PanicResult::Err(v17)
End:
  Return(v4, v5, v18)

//! > lowering_diagnostics

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

//! > test specialization with recursion

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(a: felt252, b: felt252, c: felt252) -> bool {
    let mut x = 5;
    let mut s = S { a: 1, b: 2, c: 3 };
    loop {
        bar(s);

        s.a = a;
        let y = x + 1 + s.b + s.c;

        if y == 10 {
            break true;
        }
    }
}
extern fn bar(a: S) nopanic;
#[derive(Drop, Copy)]
struct S {
    a: felt252,
    b: felt252,
    c: felt252,
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters: v0: core::felt252, v1: core::felt252, v2: core::felt252
blk0 (root):
Statements:
  (v3: core::felt252) <- 5
  (v4: core::felt252) <- 1
  (v5: core::felt252) <- 2
  (v6: core::felt252) <- 3
  (v7: test::S) <- struct_construct(v4, v5, v6)
  (v9: core::felt252, v8: core::bool) <- test::foo[112-254](v7, v0, v3)
  (v10: core::felt252, v11: core::felt252, v12: core::felt252) <- struct_destructure(v7)
End:
  Return(v8)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252, v3: core::felt252, v4: core::felt252
blk0 (root):
Statements:
  (v5: core::RangeCheck, v6: core::gas::GasBuiltin, v7: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[112-254]{{ 1, 2, 3 }, NotSpecialized, 5, }(v0, v1, v2)
End:
  Match(match_enum(v7) {
    PanicResult::Ok(v8) => blk1,
    PanicResult::Err(v9) => blk2,
  })

blk1:
Statements:
  (v10: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v6)
  (v11: core::felt252, v12: core::bool) <- struct_destructure(v8)
  (v13: (core::bool,)) <- struct_construct(v12)
  (v14: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Ok(v13)
End:
  Return(v5, v10, v14)

blk2:
Statements:
  (v15: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Err(v9)
End:
  Return(v5, v6, v15)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: test::S, v1: core::felt252, v2: core::felt252
blk0 (root):
Statements:
  () <- test::bar(v0)
  (v3: core::felt252, v4: core::felt252, v5: core::felt252) <- struct_destructure(v0)
  (v6: core::felt252) <- 1
  (v7: core::felt252) <- core::Felt252Add::add(v2, v6)
  (v8: core::felt252) <- core::Felt252Add::add(v7, v4)
  (v9: core::felt252) <- core::Felt252Add::add(v8, v5)
  (v10: core::felt252, v11: @core::felt252) <- snapshot(v9)
  (v12: core::felt252) <- 10
  (v13: core::felt252, v14: @core::felt252) <- snapshot(v12)
  (v15: core::bool) <- core::Felt252PartialEq::eq(v11, v14)
End:
  Match(match_enum(v15) {
    bool::False(v17) => blk2,
    bool::True(v16) => blk1,
  })

blk1:
Statements:
  (v18: ()) <- struct_construct()
  (v19: core::bool) <- bool::True(v18)
End:
  Return(v1, v19)

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

blk3:
Statements:
  (v20: test::S) <- struct_construct(v1, v4, v5)
  (v22: core::felt252, v21: core::bool) <- test::foo[112-254](v20, v1, v2)
  (v23: core::felt252, v24: core::felt252, v25: core::felt252) <- struct_destructure(v20)
End:
  Return(v22, v21)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: test::S, v3: core::felt252, v4: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v5, v6) => blk1,
    Option::None(v7, v8) => blk4,
  })

blk1:
Statements:
  () <- test::bar(v2)
  (v9: core::felt252, v10: core::felt252, v11: core::felt252) <- struct_destructure(v2)
  (v12: core::felt252) <- 1
  (v13: core::felt252) <- core::felt252_add(v4, v12)
  (v14: core::felt252) <- core::felt252_add(v13, v10)
  (v15: core::felt252) <- core::felt252_add(v14, v11)
  (v16: core::felt252) <- 10
  (v17: core::felt252) <- core::felt252_sub(v15, v16)
End:
  Match(match core::felt252_is_zero(v17) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v18) => blk3,
  })

blk2:
Statements:
  (v19: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v6)
  (v20: ()) <- struct_construct()
  (v21: core::bool) <- bool::True(v20)
  (v22: (core::felt252, core::bool)) <- struct_construct(v3, v21)
  (v23: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Ok(v22)
End:
  Return(v5, v19, v23)

blk3:
Statements:
  (v24: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v6)
  (v25: test::S) <- struct_construct(v3, v10, v11)
  (v26: core::RangeCheck, v27: core::gas::GasBuiltin, v28: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[112-254](v5, v24, v25, v3, v4)
End:
  Return(v26, v27, v28)

blk4:
Statements:
  (v29: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v30: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v29)
End:
  Return(v7, v8, v30)


Final lowering of specialized call "test::foo[112-254]{{ 1, 2, 3 }, NotSpecialized, 5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v8: core::felt252) <- 1
  (v9: core::felt252) <- 2
  (v10: core::felt252) <- 3
  (v11: test::S) <- struct_construct(v8, v9, v10)
  () <- test::bar(v11)
  (v12: core::RangeCheck, v13: core::gas::GasBuiltin, v14: core::panics::PanicResult::<(core::felt252, core::bool)>) <- test::foo[112-254]{{ NotSpecialized, 2, 3 }, NotSpecialized, 5, }(v3, v7, v2, v2)
End:
  Return(v12, v13, v14)

blk2:
Statements:
  (v15: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v16: core::panics::PanicResult::<(core::felt252, core::bool)>) <- PanicResult::Err(v15)
End:
  Return(v5, v6, v16)

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

//! > test coerce non-specialization with recursion

//! > test_runner_name
test_generated_function

//! > function_code
fn foo(s: S) -> bool {
    let x = 5;
    let mut o = Outer { a: 1, s: s };
    loop {
        bar(o);

        o.s = S { a: x };
        if x == 10 {
            break true;
        }
    }
}
extern fn bar(a: Outer) nopanic;
#[derive(Drop, Copy)]
struct S {
    a: felt252,
}

#[derive(Drop, Copy)]
struct Outer {
    a: felt252,
    s: S,
}

//! > function_name
foo

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:

//! > lowering
Main:
Parameters: v0: test::S
blk0 (root):
Statements:
  (v1: core::felt252) <- 5
  (v2: core::felt252) <- 1
  (v3: test::Outer) <- struct_construct(v2, v0)
  (v5: test::S, v4: core::bool) <- test::foo[76-191](v3, v1)
  (v6: core::felt252, v7: test::S) <- struct_destructure(v3)
End:
  Return(v4)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: test::S
blk0 (root):
Statements:
  (v3: core::RangeCheck, v4: core::gas::GasBuiltin, v5: core::panics::PanicResult::<(test::S, core::bool)>) <- test::foo[76-191]{{ 1, NotSpecialized }, 5, }(v0, v1, v2)
End:
  Match(match_enum(v5) {
    PanicResult::Ok(v6) => blk1,
    PanicResult::Err(v7) => blk2,
  })

blk1:
Statements:
  (v8: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v9: test::S, v10: core::bool) <- struct_destructure(v6)
  (v11: (core::bool,)) <- struct_construct(v10)
  (v12: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Ok(v11)
End:
  Return(v3, v8, v12)

blk2:
Statements:
  (v13: core::panics::PanicResult::<(core::bool,)>) <- PanicResult::Err(v7)
End:
  Return(v3, v4, v13)


Generated loop lowering for source location:
      loop {
 _____^
| ...
|     }
|_____^

Parameters: v0: test::Outer, v1: core::felt252
blk0 (root):
Statements:
  () <- test::bar(v0)
  (v2: test::S) <- struct_construct(v1)
  (v3: core::felt252, v4: test::S) <- struct_destructure(v0)
  (v5: core::felt252, v6: @core::felt252) <- snapshot(v1)
  (v7: core::felt252) <- 10
  (v8: core::felt252, v9: @core::felt252) <- snapshot(v7)
  (v10: core::bool) <- core::Felt252PartialEq::eq(v6, v9)
End:
  Match(match_enum(v10) {
    bool::False(v12) => blk2,
    bool::True(v11) => blk1,
  })

blk1:
Statements:
  (v13: ()) <- struct_construct()
  (v14: core::bool) <- bool::True(v13)
End:
  Return(v2, v14)

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

blk3:
Statements:
  (v15: test::Outer) <- struct_construct(v3, v2)
  (v17: test::S, v16: core::bool) <- test::foo[76-191](v15, v5)
  (v18: core::felt252, v19: test::S) <- struct_destructure(v15)
End:
  Return(v17, v16)


Final lowering:
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: test::Outer, v3: core::felt252
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v4, v5) => blk1,
    Option::None(v6, v7) => blk4,
  })

blk1:
Statements:
  () <- test::bar(v2)
  (v8: core::felt252) <- 10
  (v9: core::felt252) <- core::felt252_sub(v3, v8)
  (v10: test::S) <- struct_construct(v3)
End:
  Match(match core::felt252_is_zero(v9) {
    IsZeroResult::Zero => blk2,
    IsZeroResult::NonZero(v11) => blk3,
  })

blk2:
Statements:
  (v12: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v5)
  (v13: ()) <- struct_construct()
  (v14: core::bool) <- bool::True(v13)
  (v15: (test::S, core::bool)) <- struct_construct(v10, v14)
  (v16: core::panics::PanicResult::<(test::S, core::bool)>) <- PanicResult::Ok(v15)
End:
  Return(v4, v12, v16)

blk3:
Statements:
  (v17: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v5)
  (v18: core::felt252, v19: test::S) <- struct_destructure(v2)
  (v20: test::Outer) <- struct_construct(v18, v10)
  (v21: core::RangeCheck, v22: core::gas::GasBuiltin, v23: core::panics::PanicResult::<(test::S, core::bool)>) <- test::foo[76-191](v4, v17, v20, v3)
End:
  Return(v21, v22, v23)

blk4:
Statements:
  (v24: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v25: core::panics::PanicResult::<(test::S, core::bool)>) <- PanicResult::Err(v24)
End:
  Return(v6, v7, v25)


Final lowering of specialized call "test::foo[76-191]{{ 1, NotSpecialized }, 5, }":
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin, v2: test::S
blk0 (root):
Statements:
End:
  Match(match core::gas::withdraw_gas(v0, v1) {
    Option::Some(v3, v4) => blk1,
    Option::None(v5, v6) => blk2,
  })

blk1:
Statements:
  (v7: core::gas::GasBuiltin) <- core::gas::redeposit_gas(v4)
  (v8: core::felt252) <- 1
  (v9: test::Outer) <- struct_construct(v8, v2)
  () <- test::bar(v9)
  (v10: core::felt252) <- 5
  (v11: test::S) <- struct_construct(v10)
  (v12: test::Outer) <- struct_construct(v8, v11)
  (v13: core::RangeCheck, v14: core::gas::GasBuiltin, v15: core::panics::PanicResult::<(test::S, core::bool)>) <- test::foo[76-191]{NotSpecialized, 5, }(v3, v7, v12)
End:
  Return(v13, v14, v15)

blk2:
Statements:
  (v16: (core::panics::Panic, core::array::Array::<core::felt252>)) <- core::panic_with_const_felt252::<375233589013918064796019>()
  (v17: core::panics::PanicResult::<(test::S, core::bool)>) <- PanicResult::Err(v16)
End:
  Return(v5, v6, v17)
