out.push(xs[i]), String) reaches rustc instead of a refusal naming the copyOpen and answer this issue on GitHub.
ready · opened 2026-10-28 · updated 2026-10-31 · 1 comment
Probe
fn lines() -> Vec[String] {
return ["a", "b"]
}
fn main() {
let rest = lines()
let mut out: Vec[String] = []
for i in 0..<rest.len() {
out.push(rest[i])
}
println(out.join(","))
}
The lowering is out.push(*nikaia_std::index::get(&rest, i as usize)), and rustc answers Cannot move out of a shared reference.
The language never copies unseen (Part I, with: “never copied unseen … the refusal names the copy to write”), so rest[i].clone() is the right program. But the checker should say so itself, as an NK refusal with the help rest[i].clone(), and the error should not be rustc’s. This was met in the converter (tr_stmt.nika) and corrected there with .clone().
To build
Copy nor a view, when it is handed somewhere that keeps it (a call argument by value, let, return). The help writes .clone(). This needs a new NK code from the supervisor’s block.tests/compiler/tests/*.nika + .stderr.A second probe, found by the yaml lane (y3, d715e425): an owned field moved out through an index of a ref list.
struct Node { raw: String }
struct Ev { raw: String }
fn first(ns: ref Vec[Node]) -> Ev {
return Ev { raw: ns[0].raw }
}
This reaches rustc (“cannot move out of a shared reference”), on develop before and after d715e425. The same read through a plain reference, n.raw with n: ref Node, is refused NK2106. Cause, per the builder: check_arm_leaves.hands_over_read_at needs a read path (bounds_basic.path_of), and a path has no Index segment. So step 1 above should cover a field below an index (xs[i].f) as well as the element itself, and its help writes ns[0].raw.clone(); a second .stderr test for this probe. Nothing in packages/yaml needs it.
Generated by Claude Code