LYR-SEM0046
a lambda that can end without its value
A block lambda whose result is not void — a generator lambda with a result, or a lambda an inline function sets in place — has a path that ends its body without returning the value.
Explanation
A lambda that gives a result gives it on every path, like a function. A generator lambda that returns on one path returns on all of them; a lambda an inline function sets in place gives its value as its last expression, since a return there leaves the enclosing function.
Return on every path, or end the body with the value as its tail expression.
Wrong
fn main(): void {
let g = (early: bool) => {
yield 1;
if (early) { return "early"; }
};
let _ = g(true);
}
Right
fn main(): void {
let g = (early: bool) => {
yield 1;
if (early) { return "early"; }
return "late";
};
let _ = g(true);
}