LYR-PAR0036
an if expression without 'else'
An if in expression position — after =, as an argument, without braces around its branch — has no else branch.
Explanation
An if that gives a value gives one on both paths: if (c) a else b. Without the else there would be no value when the condition is false. An if without else is a statement, and its branches are blocks.
Write the else branch, or make the if a statement.
Wrong
fn main(): void {
let ok = true;
let s = if (ok) "yes" "no";
}
Right
fn main(): void {
let ok = true;
let s = if (ok) "yes" else "no";
let _ = s;
}