//! > Test inlining diagnostics for a recursive function.
//! > test_runner_name
test_function_inlining
//! > function
#[inline(always)]
fn foo(ref a: felt252, b: felt252) -> felt252 {
foo(ref a, b);
b
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > lowering_diagnostics
error: Cannot inline a function that might call itself.
--> lib.cairo:1:1
#[inline(always)]
^***************^
//! > before
Parameters: v0: core::felt252, v1: core::felt252
blk0 (root):
Statements:
(v3: core::felt252, v2: core::felt252) <- test::foo(v0, v1)
End:
Return(v3, v1)
//! > after
Parameters: v0: core::felt252, v1: core::felt252
//! > ==========================================================================
//! > Test inlining a function where the the last block does not return.
//! > test_runner_name
test_function_inlining
//! > function_name
foo
//! > function
fn foo(n: felt252) -> felt252 {
bar(n)
}
//! > module_code
#[inline(always)]
fn bar(n: felt252) -> felt252 {
if n == 0 {
return 1;
} else {
return 1;
}
}
//! > semantic_diagnostics
//! > before
Parameters: v0: core::felt252
blk0 (root):
Statements:
(v1: core::felt252) <- test::bar(v0)
End:
Return(v1)
//! > after
Parameters: v0: core::felt252
blk0 (root):
Statements:
End:
Goto(blk2, {})
blk1:
Statements:
End:
Return(v1)
blk2:
Statements:
End:
Match(match core::felt252_is_zero(v0) {
IsZeroResult::Zero => blk3,
IsZeroResult::NonZero(v2) => blk4,
})
blk3:
Statements:
(v3: core::felt252) <- 1u
End:
Goto(blk1, {v3 -> v1})
blk4:
Statements:
(v4: core::felt252) <- 1u
End:
Goto(blk1, {v4 -> v1})
//! > lowering_diagnostics