Issue #2922: A sequence handed to a generic function of the program’s own passes the checker and is refused by rustc

Open and answer this issue on GitHub.

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

Found while “A chain over io::lines() is one loop the compiler writes, and the view steps leave Rust (ADR-342 D6, the Rust of #2881)” (#2899), builder’s step 1, at 56f8c93f.

What is wrong

use std::io

fn hand[T](x: T) -> T {
    return x
}

fn main() throws {
    let s = hand(io::lines().filter(fn(l) { l.len() > 1 }))
    println(f"{s.count()}")
}

The checker accepts this, and rustc refuses the output (NK1343: “std::sync::mpsc::Receiver<...> cannot be shared between threads safely”). With let xs = [1, 2, 3]; let s = hand(xs.iter().map(fn(x) { x + 1 })), rustc reports “xs does not live long enough”. The same happens through fn pass[T](h: Holder[T]) -> Holder[T]. ADR-105 D4 says no walk is handed to a function of the program’s own, and par_iter_to_a_function.nika refuses it for a Par. A type variable bound to a Seq slips past that check; the suspected place is the checker’s argument check (check_arguments.nika, not traced).

To build

  1. The checker refuses a Seq bound to a type variable of the program’s own function, directly or inside a generic struct, with the code and message ADR-105 D4’s refusal of a Par uses (or its Seq twin, if one exists). Fixed in .nika, then lower-std.
  2. A test tests/compiler/tests/a_sequence_handed_to_a_generic_function_is_refused.nika with .stderr, covering hand(...) and pass(Holder { v: ... }).

Done when

Both probes are refused by the checker, the test passes, and the commit carries Fixes #N.

Files and limits

The checker’s .nika files and their lowered output, the test. No new Rust.

Facts: Checker and views, Lowering and lower-std

Back to Open Issues