Lyricdev
GitHub

LYR-SEM0102

a label that repeats the label of an enclosing loop

error ยท spec 07-statements

A loop is labeled with a name a loop around it already carries.

Explanation

Labels of nested loops are distinct: with two loops named outer, a break outer inside both would have two candidates, and choosing the nearer one silently is how the far one stops being reachable. Loops side by side may share a label; only nesting is refused.

Rename one of the two labels.

Wrong

fn main(): void {
    outer: loop {
        outer: loop { break outer; }
        break outer;
    }
}
fn main(): void {
    outer: loop {
        loop { break outer; }
    }
}