//! > Call with coupon

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: bar::Coupon) {
    bar(__coupon__: x);
}

//! > function_name
foo

//! > module_code
fn bar() nopanic {}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::bar::Coupon
blk0 (root):
Statements:
End:
  Return()

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

//! > Call method with impl function coupon

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: MyImpl::bar::Coupon) {
    5.bar(__coupon__: x);
}

//! > function_name
foo

//! > module_code
trait MyTrait<T> {
    fn bar(self: T);
}
impl MyImpl of MyTrait<felt252> {
    fn bar(self: felt252) {}
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::MyImpl::bar::Coupon
blk0 (root):
Statements:
End:
  Return()

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

//! > Call method with concrete trait function coupon

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: MyTrait::<felt252>::bar::Coupon) {
    5.bar(__coupon__: x);
}

//! > function_name
foo

//! > module_code
trait MyTrait<T> {
    fn bar(self: T);
}
impl MyImpl of MyTrait<felt252> {
    fn bar(self: felt252) {}
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::MyImpl::bar::Coupon
blk0 (root):
Statements:
End:
  Return()

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

//! > Coupon moved

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: bar::Coupon) -> bar::Coupon {
    bar(__coupon__: x);
    x // Variable was previously moved.
}

//! > function_name
foo

//! > module_code
fn bar() nopanic {}

//! > semantic_diagnostics

//! > lowering_diagnostics
error: Variable was previously moved.
 --> lib.cairo:4:5
    x // Variable was previously moved.
    ^
note: variable was previously used here:
  --> lib.cairo:3:21
    bar(__coupon__: x);
                    ^
note: Trait has no implementation in context: core::traits::Copy::<test::bar::Coupon>.

//! > lowering_flat
Parameters: v0: test::bar::Coupon

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

//! > Calling panicable function with coupon

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: bar::Coupon) {
    bar(__coupon__: x);
}

//! > function_name
foo

//! > module_code
fn bar() {
    panic(array![])
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::bar::Coupon
blk0 (root):
Statements:
  (v1: core::array::Array::<core::felt252>) <- core::array::array_new::<core::felt252>()
  (v2: core::panics::Panic) <- struct_construct()
  (v3: (core::panics::Panic, core::array::Array::<core::felt252>)) <- struct_construct(v2, v1)
  (v4: core::panics::PanicResult::<((),)>) <- PanicResult::Err(v3)
End:
  Return(v4)

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

//! > Inlining disabled when coupon is used.

//! > test_runner_name
test_function_lowering

//! > function
fn foo(x: bar::Coupon) {
    bar(__coupon__: x);
}

//! > function_name
foo

//! > module_code
#[inline(always)]
fn bar() {}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v0: test::bar::Coupon
blk0 (root):
Statements:
End:
  Return()
