✓
Passing Passing: the compiler rejects this program as expected.
Code
// Single-owner law: an edge arg must be a fresh mint or null. Passing a
// child that is already bound inside another node is a second consume of an
// owned binding — the obligation checker refuses.
import std/io
import std/tree
std/tree:node(Node) { item: i64, left: ?Node }
std/tree:mint(Node) { item: 1 }: inner
|> std/tree:mint(Node) { item: 2, left: inner }: a
|> std/tree:mint(Node) { item: 3, left: inner }: b
|> std/tree:dispose(a): _
|> std/tree:dispose(b): _
|> std/io:print.ln("unreachable")
Actual compiler output
error[KORU030]: Use-after-discharge: binding 'inner' was already discharged and cannot be used
--> tests/regression/600_STDLIB/682_TREE/682_009_mint_second_owner_edge/input.k:12:1Must contain:
Use-after-dischargeFlows
flow ~node click a branch to expand · @labels scroll to their anchor
node (Node, source: item: i64, left: ?Node)
flow ~mint click a branch to expand · @labels scroll to their anchor
mint (Node, source: item: 1)
Test Configuration
MUST_ERROR