✓
Passing This code compiles and runs correctly.
Code
// PINS: an OWNED obligation carried across a label-fold back-edge, via the
// consume-in / issue-out (1:1 conserved) shape, with the SEED issued by a leaf.
//
// Lars's design hypothesis, which this holds: carrying an obligation through a
// label-fold is sound IFF each back-edge iteration CONSUMES the carried
// obligation and ISSUES exactly one to carry forward — net zero inside, one
// seeded in, one escaping to an outside disposer. That respects directionality:
// the body event consumes on its INPUT and issues on its OUTPUT, and `@loop`
// routes output -> input.
//
// spin = make(): h0 |> #loop step(h: h0) make ISSUES <owned!> (h0), seeds the fold
// | again v |> @loop(h: v) back-edge carries the re-issued handle
// | stop r -> r escapes it to the outside disposer
//
// step CONSUMES <!owned> on input and RE-ISSUES <owned!> on each output branch;
// `done` is the single outside disposer.
//
// SEED SHAPE (vs the failed 330_072): the obligation does NOT enter `spin`
// through a consuming parameter — consume-on-input discharges at the door and
// raises KORU030. An ISSUING leaf `make()` runs inside spin's flow instead.
//
// BOTH ARMS ARE SPELLED AS BRANCHES, and that is load-bearing. `step` is a
// branching tor, so it has no return value to bind: an inline
// `#loop step(h: h0): v` binds something that does not exist and owes both
// arms, which is KORU022 — pinned at 510_109. The two spellings are not
// synonyms, and only this one is a program.
//
// Grammar grounded against 210_123 (`#loop` seed + `@loop` back-edge + a
// bare-return exit) and 370_020 (obligation issued inside the loop by a leaf).
// 210_166 covers the prefix-before-fold capture in isolation, obligation-free;
// this test is the composed case where an obligation rides the same shape.
const std = @import("std");
const Handle = struct { n: i32 };
~tor make {} -> *Handle<owned!>
~proc make|zig {
const h = std.heap.page_allocator.create(Handle) catch unreachable;
h.* = .{ .n = 0 };
return h;
}
// step: consume the carried obligation on input, re-issue exactly one on output.
~tor step { h: *Handle<!owned> }
| again *Handle<owned!>
| stop *Handle<owned!>
~proc step|zig {
h.n += 1;
if (h.n < 3) return .{ .again = h };
return .{ .stop = h };
}
~tor done { h: *Handle<!owned> }
~proc done|zig {
std.debug.print("n={}\n", .{h.n});
std.heap.page_allocator.destroy(h);
}
~tor spin {} -> *Handle<owned!>
// Seed the fold from an ISSUING leaf, then consume-in/issue-out across @loop.
~spin = make(): h0 |> #loop step(h: h0)
| again v |> @loop(h: v)
| stop r -> r
~spin(): hf |> done(h: hf)
Actual
n=3
Expected output
n=3
Flows
subflow ~spin click a branch to expand · @labels scroll to their anchor
make
flow ~spin click a branch to expand · @labels scroll to their anchor
spin
Test Configuration
MUST_RUN