Issue #2942: A lambda over zip’s pairs cannot read the pair: p.0 gives NK1245

Open and answer this issue on GitHub.

bug, ready · opened 2026-11-29 · updated 2026-11-29 · 0 comments

Probe

fn main() throws {
    let xs = [1, 2, 3]
    let ys = [4, 5, 6]
    let a = xs.iter().zip(ys.iter()).map(fn(p) { p.0 + p.1 }).sum()
    println(f"{a}")
}

This gives NK1245 (“The compiler can’t tell what type p.0 is”). It fails the same way on c2554dfb and on the tree of the second run of “Chains over lists, maps and std’s other producers are one loop the compiler writes, and seq.rs leaves Rust (ADR-chain-loop-v1 D6, D7)” (#2927). A for (x, y) over the same zip runs.

Expected

The program prints 21, just as xs.iter().enumerate().map(fn(p) { p.0 + p.1 }).sum() types its pair. The signature of Seq::zip in std.contracts, [T, U](self: Seq[T], other: Seq[U]) -> Seq[(T, U)], names the pair’s type.

Suspected cause

Unknown. Possibly the checker binds the lambda’s parameter before it takes U from the argument. To check: print the receiver’s Seq item type at the map call.

To build

  1. A lambda over zip’s pairs gets the type (T, U).
  2. The probe becomes a test with its .stdout.

Done when

The probe prints 21.

Found during #2927.

Back to Open Issues