Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V7017. A loop counter is not used...
menu mobile close menu
Additional information
toggle menu Contents

V7017. A loop counter is not used for collection indexing in the inner loop.

Apr 03 2026

The analyzer has detected a possible error in two or more nested for loops, when the counter of one of the loops is not used because of a typo.

The example:

let sum = 0;
for (let i = 0; i < N; i++) {
  for (let j = 0; j < M; j++) {
    sum += matrix[i][i];     // <=
  }
}

In this case, it is intended to process all elements of a matrix and sum up them, but i is used instead of j when indexing the columns.

The fixed code:

let sum = 0;
for (let i = 0; i < N; i++) {
  for (let j = 0; j < M; j++) {
    sum += matrix[i][j]; 
  }
}