Issue #968: for mut x in grid[i] (an index place) is refused NK1139 “isn’t supported yet”

Open and answer this issue on GitHub.

ready · opened 2026-10-29 · updated 2026-10-29 · 0 comments

Found while building #951 (steps 1-3, b951a report).

ADR-views-2 D2 says that when a for walks a place, which is “a name, a field or an index of a list”, the element is a let mut view. Today only a name or a field path works. An index place (for mut x in grid[i]) and a safe field are refused with NK1139 “isn’t supported yet”. So this is a defect against the ADR.

Probe

fn main() {
    let mut grid: Vec[Vec[i64]] = [[1, 2], [3]]
    for mut x in grid[0] { x += 10 }
    print(grid[0][0])
}

Expected 11.

To build

  1. The mutable list place of for mut (and of a let mut view, for the same reason) accepts an index of a list. It lowers grid[0].iter_mut(). Indexes nested under fields work too.
  2. A safe field: either build it, or name it in the ADR as not yet supported, with its own sentence.
  3. Tests in tests/compiler.

Back to Open Issues