Esc

infinite_loop

Finds a while whose condition nothing in the loop changes.

Category suspicious, warn by default.

Example
#import "Basic";

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

    while i < values.count {
        total += values[i];
    }

    return total;
}

main :: () {
    print("%\n", sum(.[1, 2, 3]));
}
Diagnostic
warning[infinite_loop]: this loop's condition never changes inside it
  --> example.jai:7:11
   |
 7 |     while i < values.count {
   |           ^^^^^^^^^^^^^^^^
   |
   = help: nothing in the loop assigns `i` or `values`, and it has no `break` or `return`: once entered it never ends
   = note: `infinite_loop` is `warn` by default
Fixed
#import "Basic";

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

    while i < values.count {
        total += values[i];
        i += 1;
    }

    return total;
}

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

Condition reads only locals, parameters and literals; skipped for bodies with break, return, #insert, #asm, using, macro calls or taken addresses.