Issue #2622: .clone() of a list of text views passed to a keeping parameter is accepted, then fails in rustc (NK1343)

Open and answer this issue on GitHub.

ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments

Found while building the TOML reader for the compiler (#2602), map of lists. Area: checker (views).

Probe (target/fast/nikaia run c1.nika)

use std::collections
fn main() throws {
	let t = "a,b"
	let v = t.split(",").collect()
	let mut m: collections::BTreeMap[String, Vec[String]] = collections::BTreeMap()
	m.insert("k", v.clone())
	println(f"{m.len()}")
}

Prints:

error[NK1343]: Internal compiler error.
  --> c1.nika:6:2
 6 | 	m.insert("k", v.clone())
   = note: Rustc output: mismatched types.
   = note: Expected struct `List<nikaia_std::block::Text>`
   found struct `List<&str>`

The same value given to a struct field is refused correctly:

struct H { xs: Vec[String], }
fn main() throws {
	let t = "a,b"
	let v = t.split(",").collect()
	let h = H { xs: v.clone() }
	println(f"{h.xs.len()}")
}

It gives error[NK1106]: H.xs holds a Vec[String] whose items are their own, but you're giving it a Vec[String] whose items are views.

Expected

The checker refuses the call, as it refuses the struct-field case, because collections::BTreeMap::insert keeps its value after the call returns, and a Vec[String] whose items are views is not one of its own (ADR-282 D12, text tiers). It must not hand rustc a program rustc refuses. Which code it gets (NK1102 for a kept argument, or NK1106 as for the field) is not yet checked against the code; the builder takes the one whose text names a kept argument.

Cause (suspected)

check_arguments.nika, the NK1102 branch around line 805 (state.a_view_kept(found_here, want, named, keeper)): it looks at whether the argument as a whole is a view, not at the tier of its items. Settling check: a trace of a_view_kept for the probe, which should show it returning null.

To build

  1. Make the keeping-argument check see a list whose items are views (the item tier the struct-field check NK1106 already reads), and refuse it, with a note that names the items.
  2. Add test tests/compiler/tests/a_kept_list_of_text_views_is_refused.nika with its .stderr (the whole refusal).

Done when

The probe is refused at line 6 by the checker under both settings, and no NK1343 comes from it.

Back to Open Issues