✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS: an owned column fed from another row's PROJECTION must refuse.
// insert into an owned column consumes the caller's <instance!> (690_053's
// contract — ownership moves INTO the store); `r.name` is a borrow off store
// `a`, which keeps owning its instance. Accepting the projection makes two
// stores own one pointer, and both teardowns free it — single ownership is
// the invariant the whole obligation surface rests on, so the write site is
// where this must stop, with the verb and the owned column named.
//
// This is the serialize hole's sharpest edge: rebuilding a store row by row
// (690_124/690_194) reaches owned columns and needs a copying spelling —
// a fresh instance per rebuilt row — because the moving one is refused here.
import std/io
import std/string
import std/store
std/store:new(a, capacity: 2) { name: *std/string:String<instance!> }
std/store:new(b, capacity: 2) { name: *std/string:String<instance!> }
std/string:from-page(text: "x")
| ok s |> std/string:take(s): m |> std/store:insert(a) { name: m }
| row _ |> _
| err _ |> _
std/store:query(a)
! query r |> std/store:insert(b) { name: r.name }
std/store:query(b)
! query w |> std/io:print.ln("b {{ w.name:S }}")
Actual compiler output
error[KORU161]: std/store:insert(b): column 'name' is owned - its value must be an instance the caller gives up (single ownership, 690_053); a row projection is a borrow the source store still owns, and accepting it would put one pointer under two teardowns. Take or build a fresh instance for this row instead.
--> tests/regression/600_STDLIB/690_STORE/690_195_owned_column_insert_from_projection/input.k:24:0Must contain:
std/store:insertFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (a, capacity: 2, source: name: *std/string:String<instance!>)
flow ~new click a branch to expand · @labels scroll to their anchor
new (b, capacity: 2, source: name: *std/string:String<instance!>)
flow ~from-page click a branch to expand · @labels scroll to their anchor
from-page (text: "x")
flow ~query click a branch to expand · @labels scroll to their anchor
query (a)
flow ~query click a branch to expand · @labels scroll to their anchor
query (b)
Test Configuration
MUST_ERROR LANGUAGES: zig cs