A when guard only decides whether a clause or arm applies; it must be pure and can't fail or
return. The same goes for a module constant's initializer.
Wrong#
fn positive(s: str): bool when int.parse(s)? > 0 = true
fn positive(_: str): bool = falseFixed#
fn positive(s: str): bool when (int.parse(s) else 0) > 0 = true
fn positive(_: str): bool = falseCommon causes#
?on a fallible call in a guard: give a fallback withelse.returninside a guard: compute the condition in the body instead.- A fallible constant: compute it in
mainand pass it where it's needed.