✓
Passing This code compiles and runs correctly.
Code
// REQUIREMENT (effect-branch obligations, no-escape negative — the discriminator):
// The `! each` signature carries NO `<state!>` resume, so an obligation created
// in the handler CANNOT escape the firing. Here the handler creates an `active!`
// obligation and only USES it (no discharge, no destroy event) — so it is
// unbalanced and MUST be rejected. (Mirror of old-for 330_053 on the new path.)
// If this is silently accepted, obligation tracking is NOT wired through `! each`.
~import std/build
~std/build:requires { exe.linkLibC(); }
const std = @import("std");
const Resource = struct { id: usize };
const allocator = std.heap.c_allocator;
~tor create { id: usize } -> *Resource<active!>
~proc create|zig {
const r = allocator.create(Resource) catch unreachable;
r.* = Resource{ .id = id };
return r;
}
~tor use { r: *Resource<active> }
~proc use|zig { std.debug.print("using {}\n", .{r.id}); }
~pub tor gen { n: usize }
! each usize
| done usize
~proc gen|zig {
for (0..n) |i| { each(i); }
return .{ .done = n };
}
~gen(n: 3)
! each i |> create(id: i): r |> use(r)
| done _ |> _
Backend must reject with:
CONTAINS error[KORU030]
CONTAINS was not dischargedFlows
flow ~requires click a branch to expand · @labels scroll to their anchor
requires (source: exe.linkLibC();)
flow ~gen click a branch to expand · @labels scroll to their anchor
gen (n: 3)