Esc

index_only_loop

Finds for i: 0..xs.count-1 where i only indexes xs.

Category complexity, warn by default.

Example
#import "Basic";

sum :: (xs: [] int) -> int {
    total := 0;

    for i: 0..xs.count - 1 {
        total += xs[i];
    }

    return total;
}

main :: () {
    print("%\n", sum(.[1, 2, 3]));
}
Diagnostic
warning[index_only_loop]: `i` is only used to index `xs`
  --> example.jai:6:5
   |
 6 |     for i: 0..xs.count - 1 {
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |
help: loop over the elements: `for xs` and `it`
   |
 6 ~     for xs {
 7 ~         total += it;
   |
   = note: `index_only_loop` is `warn` by default
Fixed
#import "Basic";

sum :: (xs: [] int) -> int {
    total := 0;

    for xs {
        total += it;
    }

    return total;
}

main :: () {
    print("%\n", sum(.[1, 2, 3]));
}

Becomes for xs (or for *xs when elements are written), other uses of i become it_index.