LYR-PAR0065
a 'continue', 'break' or 'return' where a value stands
A jump stands where an expression is wanted — a match arm, a branch of an if expression —; it is a statement and goes in a block, => { continue; }.
Explanation
continue, break and return are statements: they leave, and give no value. Where an arm of a match or a branch of an if expression wants a value, a block holds the statement, and a block that leaves is worth never, which fits any arm. The compiler reads the jump as that block and checks the other arms as usual.
lyric fix writes the block: ' ' => continue, becomes ' ' => { continue; },.
Wrong
fn main(): void {
for (c in "a b".chars()) {
let n = match (c) {
' ' => continue,
_ => 1,
};
let _ = n;
}
}
Right
fn main(): void {
for (c in "a b".chars()) {
let n = match (c) {
' ' => { continue; },
_ => 1,
};
let _ = n;
}
}