Issue #2947: A sum of a chain over a range whose numbers nothing types does not compile (NK1343: type annotations needed)

Open and answer this issue on GitHub.

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

Probe

fn main() throws {
    let n = 10
    let mut total = 0
    for r in 0..<2 { total += (0..<n).map(fn(i) { i * 2 + r }).sum() }
    println(f"{total}")
}

This gives NK1343 (rustc: type annotations needed, multiple impls satisfying i64: AddAssign<_>). Seen with the compiler built at 26182f11. With let n: i64 = 10 and let mut total: i64 = 0 it compiles.

Expected

It prints 200. An integer that nothing names is i64 (Part I).

Suspected cause

check_numbers3.nika writes facts.summed only where the open number class is decided or typed (if decided != null || typed), so .sum() gets no ::<i64>. To check: print facts.summed for the sum’s receiver. It may share its cause with “An unannotated integer list that is summed becomes Vec, and a collect from it into Vec[i64] fails (NK1343)" (#2943).

To build

  1. A sum over open integers is summed as i64 when nothing names another type.
  2. The probe becomes a test with its .stdout.

Done when

The probe prints 200.

Found during “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).

Back to Open Issues