✓
Passing This code compiles and runs correctly.
Code
// 690_059 — EXPLICIT field-projection discharge on a SINGLE-field store row.
// A store row is a synthesized aggregate (record), NOT a user-authored type, so
// "no single-item records" doesn't govern it: even a one-owned-column row is a
// record `{ r }`, and `it.r` field-projection discharge works. Here `take` yields
// `| item it` (it.r holds <owned!>) and the caller EXPLICITLY discharges it via
// `free(it.r)` (not auto-discharge). Proves the field-narrowing / record-field
// discharge machinery applies to single-field store rows — the substrate the
// drain rung's `! discharge item |> …(item.field)` relies on.
import std/io
import std/store
import app/lib/res
std/store:new(things, capacity: 8) { r: *app/lib/res:Resource<owned!> }
app/lib/res:new(): res |> std/store:insert(things) { r: res }
| row row |> std/store:take(things[row])
| item it |> app/lib/res:free(it.r) |> std/io:print.ln("explicitly freed")
Actual
explicitly freed
Expected output
explicitly freed
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: things, capacity: 8, source: r: *app/lib/res:Resource<owned!>)
flow ~new click a branch to expand · @labels scroll to their anchor
new
Imported Files
// A minimal OWNED-POINTER resource type (non-string), for generalizing B-narrow
// past std/string. `new` issues <owned!>; `free` is the canonical VOID
// discharger consuming <!owned>; `tag` borrows to read a field.
const std = @import("std");
const Resource = struct { tag: i64 };
~pub tor new { } -> *Resource<owned!>
~proc new|zig {
const r = std.heap.page_allocator.create(Resource) catch unreachable;
r.* = .{ .tag = 42 };
return r;
}
// Canonical discharger: consumes <!owned>, frees the resource. Void (no output).
~pub tor free { r: *Resource<!owned> }
~proc free|zig {
std.heap.page_allocator.destroy(r);
}
// Borrow: read the tag without consuming the obligation.
~pub tor tag { r: *Resource<owned> } -> i64
~proc tag|zig {
return r.tag;
}
Test Configuration
MUST_RUN