Lyricdev
GitHub

LYR-PAR0021

a for loop without 'in'

error · spec 07-statements

The header of a for loop has its variable or pattern but no in before what it walks.

Explanation

A for loop is written for (x in xs) { … }: the variable, in, and the value walked.

Write in between the variable and the value.

Wrong

fn main(): void {
    let xs = [1, 2];
    for (x xs) {
    }
}
fn main(): void {
    let xs = [1, 2];
    for (x in xs) {
        let _ = x;
    }
}