✓
Passing This code compiles and runs correctly.
Code
// 690_058 — the drain ENFORCEMENT (negative). An ambiguous *Transaction<active!>
// column with NO `! discharge` handler bolted onto the store: the store refuses
// the declaration (teaching error at the store), so the insert never consumes
// t1's obligation and the undischarged-obligation leak fires loudly (KORU030:
// "multiple discharge options: rollback, commit"). Proves koru FORCES the drain
// (no silent drop of ambiguous elements).
import std/store
import app/lib/tx
std/store:new(txns, capacity: 8) { tx: *app/lib/tx:Transaction<active!> }
app/lib/tx:begin(): t1 |> std/store:insert(txns) { tx: t1 }
| row _ |> _
Must contain:
multiple discharge optionsFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: txns, capacity: 8, source: tx: *app/lib/tx:Transaction<active!>)
flow ~begin click a branch to expand · @labels scroll to their anchor
begin
Imported Files
// An AMBIGUOUS owned resource: *Transaction<active!> with TWO void dischargers
// consuming <!active> — commit AND rollback. The store cannot pick, so an owned
// column of this type must be DRAINED (caller discharges each element), not
// auto-torn-down. (Mirrors 690_035's entity ambiguity one level down.)
const std = @import("std");
const Transaction = struct { id: i32 };
~pub tor begin { } -> *Transaction<active!>
~proc begin|zig {
const t = std.heap.page_allocator.create(Transaction) catch unreachable;
t.* = .{ .id = 7 };
return t;
}
~pub tor commit { tx: *Transaction<!active> }
~proc commit|zig {
std.debug.print("commit {d}\n", .{tx.id});
std.heap.page_allocator.destroy(tx);
}
~pub tor rollback { tx: *Transaction<!active> }
~proc rollback|zig {
std.debug.print("rollback {d}\n", .{tx.id});
std.heap.page_allocator.destroy(tx);
}