Open and answer this issue on GitHub.
ready, bugs, queued · opened 2026-11-16 · updated 2026-11-29 · 0 comments
Filed by the driver from the Found: of the run of issue-1894 (#1894) (owner, 2026-11-06). Decided 2026-11-29 (supervisor): already decided by ADR-tether-v1, so this is a defect, not a decision.
Probe on develop d8fc849d (nikaia run t.nika):
fn make() -> String {
let mut g = String()
g.push_str("a b")
g
}
fn main() throws {
let mut c: Vec[ref String] = []
c = make().split(" ").collect()
println(c.len())
}
Expected 2; actual error[NK1343]: Internal compiler error, rustc temporary value dropped while borrowed. The let form (let c: Vec[ref String] = make().split(" ").collect()) prints 2.
The same defect with a let whose view leaves its block:
fn main() throws {
let mut c: Vec[ref String] = []
if true {
let v: Vec[ref String] = make().split(" ").collect()
c = v
}
println(c.len())
}
Expected 2; actual NK1343, rustc __nikaia_held_0 does not live long enough.
The same defect with a field of a call’s result:
struct Holder {
out: String,
}
fn mk() -> Holder {
let mut g = String()
g.push_str("a b")
Holder { out: g }
}
fn main() throws {
let mut c: Vec[ref String] = []
c = mk().out.split(" ").collect()
println(c.len())
}
Expected 2; actual NK1343, rustc temporary value dropped while borrowed. The let form (let c: Vec[ref String] = mk().out.split(" ").collect()) prints 2.
The same program with the buffer bound by name already runs and prints 2: let s = make() inside the if, then c = s.split(" ").collect() lowers s to __keep_frame.put(make()).
Cause: emit_core_hold_owned_receiver (crates/nikaia-std/src/compiler/emit_core_reads.nika) holds a temporary receiver only for Stmt::Let, and only as a let __nikaia_held_N that lives to the end of its block (ADR-278 D21). An assignment gets no hold at all. A view that outlives the block keeps a hold that dies too early, where a named buffer would have moved into the frame’s keep.
Neither refused nor held only to the end of the block. The temporary moves into the keep of the frame that keeps the view, as a named buffer already does. This follows from decisions that already exist:
let first.??, && or ||, a match arm, after another call in the statement, the block’s value or the result).So c = make().split(" ").collect() runs and prints 2, whether c is bound in the same block or an outer one. No new ADR and no new error code are needed.
emit_core_hold_owned_receiver (emit_core_reads.nika) holds a temporary receiver on Stmt::Assign as on Stmt::Let, through the same chain, argument and index holds.let’s view is assigned outward), the temporary goes into the frame’s keep (__keep_frame.put(...), ADR-tether-v1 D10), as a named buffer does, instead of let __nikaia_held_N.tests/compiler/tests/: the first two probes above and the field form above, each with .stdout 2.lower-std and build once.Both probes and the field form print 2 on develop, the three tests are green, and no NK1343 remains for a view of a temporary kept by an assignment.
Generated by Claude Code