LYR-SEM0182
an inline function reaches itself
An inline fn calls itself, directly or through other inline fns; reported at the call that closes the cycle.
Explanation
Each call of an inline fn is replaced by its body. A body that calls the function again, directly or through other inline functions, would be set in place without end.
Make the recursive function an ordinary fn, or break the cycle.
Wrong
inline fn down(n: int): int {
if (n <= 0) { return 0; }
return down(n - 1);
}
fn main(): void {
assert(down(3) == 0);
}
Right
fn down(n: int): int {
if (n <= 0) { return 0; }
return down(n - 1);
}
fn main(): void {
assert(down(3) == 0);
}