✓
Passing Passing: the compiler rejects this program as expected.
Code
// OWED refusal: after `send(inbox, s)` consumes s's <live!> custody into the
// vessel, the producer's binding is dead — touching `s` again must refuse.
// Poisoning at the boundary is the whole point: nothing the producer does
// after send can reach the value the consumer now owns.
import std/io
import std/proto
import std/channel
import std/pump
std/proto(Src) {
id: i64
}
pub tor mk { i: i64 } -> Src<live!>
mk -> { id: i }
pub tor dispose { s: Src<!live> } -> i64
dispose -> s.id
pub tor peek { s: Src<live> } -> i64
peek -> s.id
std/channel:new(inbox, capacity: 8) { src: Src }
std/channel(inbox)
! src v |> dispose(s: v): id |> std/io:print.ln("disposed {{ id:d }}")
mk(i: 1): s |> std/channel:send(inbox, s)
| ok |> peek(s): id |> std/io:print.ln("poisoned read {{ id:d }}")
| full |> std/io:print.ln("full")
| closed |> std/io:print.ln("closed")
std/pump:create(main)
| drained |> std/io:print.ln("drained")
std/pump(main)
! step |> inbox-step()
! live |> inbox-live()
std/pump:run(main)
Actual compiler output
error[KORU030]: Use-after-discharge: binding 's' was already discharged and cannot be used
--> tests/regression/600_STDLIB/699_CHANNEL/699_026_reuse_after_send/input.k:29:0
❌ Compiler coordination error: Phantom semantic validation failed
(set KORU_BACKEND_TRACE=1 for the backend return trace)Must fail at runtime:
Program must error when executed.
Error output must contain
already dischargedFlows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Src, source: id: i64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: inbox, capacity: 8, source: src: Src)
flow ~std/channel click a branch to expand · @labels scroll to their anchor
std/channel (inbox)
flow ~mk click a branch to expand · @labels scroll to their anchor
mk (i: 1)
flow ~create click a branch to expand · @labels scroll to their anchor
create (expr: main)
flow ~std/pump click a branch to expand · @labels scroll to their anchor
std/pump (main)
flow ~run click a branch to expand · @labels scroll to their anchor
run (main)
Test Configuration
MUST_ERROR