Issue #1922: A view of a call’s result kept by an assignment, or past its block, goes into the frame’s keep (ADR-tether-v1 D24)

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.

Found

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.

Decision

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:

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.

To build

Done when

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

Back to Open Issues