Lyricdev
GitHub

LYR-SEM0101

a jump to a label no enclosing loop carries

error · spec 07-statements

A 'break' or 'continue' names a label that no loop around it carries — usually a misspelling, or a label of a loop the statement does not stand in.

Explanation

break outer and continue outer leave or restart a loop the statement stands in, the one labeled outer. A label is visible only inside the body of the loop it labels; a loop beside the statement, or one in another function, is out of reach, and a name that is no label at all is refused. Where break name; names neither a label nor a value in scope, the label is taken to be the mistake.

Correct the label's spelling, or label the loop the jump is meant to leave.

Wrong

fn main(): void {
    var n = 0;
    outer: while (n < 3) {
        n += 1;
        while (true) { break outr; }
        continue outer;
    }
}
fn main(): void {
    var n = 0;
    outer: while (n < 3) {
        n += 1;
        while (true) { break outer; }
    }
}