E1036

E1036#

The loop label name shadows a label that is already in scope.

Loop labels must be unique within their scope. When a label name is reused within a nested scope, it shadows the outer label, which can lead to confusion about which loop is being referenced by break or continue statements.

This warning helps prevent bugs that could occur when breaking or continuing to the wrong loop level due to label shadowing. It's recommended to use distinct, descriptive label names for different loops to make the code's intent clear.

Erroneous example#

fn f(xss : Array[Array[Int]]) -> Unit {
  l~: for xs in xss {
    l~: for x in xs {
//  ^^  Warning: The label name `l` shadows a label name that is already in
//               scope.
      if x > 0 {
        break l~
      }
    }
  }
}

Suggestion#

Use distinct, descriptive label names for different loops to make the code's intent clear.