✓
Passing Passing: the compiler rejects this program as expected.
Code
// A list whose element proto carries an owned leaf must refuse: the list
// moves bytes with no custody edge, so `*mod:Type<state!>` inside the
// element is a debt the list cannot account for. The channel is the
// consumer that transits owned leaves (699_031). Same wall as the ref(X)
// no-home refusal: a field the container cannot honour fails at `new`.
import std/proto
import std/list
import app/lib/res
std/proto(Env) {
r1: *app/lib/res:Resource<owned!>
}
std/list:new(Env)
| list xs |> std/list:free(xs)
| err e |> _
Supporting 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;
}
Actual compiler output
error[KORU173]: std/list:new(Env): field 'r1' is owned ('*app/lib/res:Resource<owned!>') — a list has no custody edge to move an obligation across; std/channel is the consumer that transits owned leaves (`send` settles each path, the arm re-mints them)
--> tests/regression/600_STDLIB/698_OOP/698_019_list_owned_leaf_refused/input.k:14:0Must fail at runtime with:
CONTAINS owned
CONTAINS custody edgeError output must contain
custody edgeFlows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Env, source: r1: *app/lib/res:Resource<owned!>)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Env)
Test Configuration
MUST_ERROR