✓
Passing This code compiles and runs correctly.
Code
// 690_057 — ambiguous owned column, discharged via a bolted-on `! discharge`
// branch. *Transaction<active!> has TWO dischargers (commit|rollback), so the
// store can't pick — it requires the discharger to be declared AT the store (the
// store is static/program-lifetime, so its discharger is static too). Teardown
// (program exit) fires `! discharge item` per still-live element; the item holds
// <active!>, so the phantom checker forces the handler to discharge it.
import std/io
import std/store
import app/lib/tx
std/store:new(txns, capacity: 8) { tx: *app/lib/tx:Transaction<active!> }
! discharge item |> app/lib/tx:commit(item.tx)
app/lib/tx:begin(): t1 |> std/store:insert(txns) { tx: t1 }
| row _ |> _
app/lib/tx:begin(): t2 |> std/store:insert(txns) { tx: t2 }
| row _ |> _
std/io:print.ln("inserted")
Actual
inserted
commit 7
commit 7
Flows
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
flow ~begin click a branch to expand · @labels scroll to their anchor
begin
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "inserted")
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);
}
Test Configuration
MUST_RUN