for element over a list of views, handed back as -> String, is refused NK1104 where an index read runsOpen and answer this issue on GitHub.
bug, ready · opened 2026-11-28 · updated 2026-11-28 · 0 comments
Found while “The Rust tests of a task’s keep, a container that drops entries and a struct of views move to .nika tests, without ref” (#2849), by its builder. tether_keep::chain stays in Rust until this is fixed.
On develop 3c5592cd, target/fast/nikaia check, with an app.conf holding host = example.org:
use std::fs
struct Setting { key: String, value: String }
fn load(path: String) -> Vec[Setting] throws {
let text = fs::read_to_string(path, fs::Root::Anywhere)
let mut settings: Vec[Setting] = []
for line in text.lines() {
let parts: Vec[String] = line.split("=").collect()
if parts.len() == 2 { settings.push(Setting { key: parts[0].trim(), value: parts[1].trim() }) }
}
return settings
}
fn host_of(path: String) -> String throws {
let settings = load(path)
for s in settings { if s.key == "host" { return s.value } }
return "localhost"
}
fn main() throws { println(host_of("app.conf")) }
Expected: prints example.org. ADR-views-v4 D4/D8: the ref spelling -> ref String (with which tether_keep::chain ran) becomes -> String, the source inferred; s.value views the buffer load read, kept by the caller’s keep (ADR-tether-v1 D2).
Actual: NK1104 at return s.value (“You’re returning a view of a String, but the function is declared to return a String of its own”, help .clone()).
Shapes: let v = s.value in the loop, then return v: NK1104 too. return settings[0].value: runs. for l in all { return l } over a Vec[String] of lines from a callee: runs.
Suspected: the NK1104 comes from expect_kept_asked (check_arm_leaves.nika), which does not see a field of a for binding over a tethered list as a view of the tether, as it sees an index read. To check: the Ty of s.value against settings[0].value at that site.
for binding over a list of views carries the list’s origin as an index read does. Test: tests/compiler/tests/a_field_of_a_for_element_is_handed_back_as_a_view.nika, the probe with its config written to fs::scratch(), .stdout example.org.tether_keep::chain (crates/nikaia/tests/it/tether_keep.rs) to a .nika test without ref and remove its Rust twin (#2849’s remainder).Both tests pass, the first failed before the fix, chain is gone from tether_keep.rs; the last commit carries Fixes #N and names #2849 as finished by it (Fixes #2849 too).
check_arm_leaves.nika and the origin walk it asks, lowered files; tether_keep.rs (removal).
Facts: Checker and views, Lowering and lower-std