Issue #2908: A list of held views, or one element of it, handed to a function lowers to Rust that rustc refuses

Open and answer this issue on GitHub.

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

Found while “A keep whose views stay on one thread is counted plainly, decided as Shared’s count is (option B of #2846)” (#2892), builder’s report. It happens with either count, so it was there before that change.

What is wrong

fn count(xs: Vec[String]) -> i64 {
    return xs.len()
}

fn main() throws {
    let mut recent: Vec[String] = []
    for i in 0..<3 {
        let text = f"a{i} b{i}"
        for w in text.split(" ") {
            recent.push(w)
        }
        while recent.len() > 2 {
            recent.remove(0)
        }
    }
    println(f"{count(recent)}")
}

This should print 2. nikaia run main.nika gives NK1343 (internal compiler error) at line 16: found reference &List<Held> (with a plain keep: &List<Held<Shared[nikaia_std::tether::Keep]>>). The same happens for one element: with fn size(w: String) -> i64 { return w.len() } and println(f"{size(recent[0])}"), rustc reports found struct Held. The lowering hands a held list or element to a parameter of plain Vec[String] / String type without converting it. The suspected place is emit_arg_value in emit_core_args.nika. Part III C.1: the lowering never hands rustc a program it refuses.

To build

  1. A call argument whose place is Held (a held list, or one element of it) reaches a Vec[String] or String parameter in the form the parameter takes: a view of each element where the parameter views, and the copy the checker asks for where it owns. Fixed in the .nika emitter, then lower-std.
  2. Tests in tests/compiler/tests/ with .stdout: both probes print 2, at both counts (a keep counted plainly and one that a task borrows).

Done when

Both probes print 2, the tests pass, and the commit carries Fixes #N.

Files and limits

The emitter’s .nika files and their lowered output, the tests. No new Rust.

Facts: Lowering and lower-std

Back to Open Issues