✗
Failing This test is currently failing.
Failed: frontend
Failure Output
error[PARSE003]: single continuation branch 'finished' carrying a payload is a one-variant tag union — declare the single output as a bare return instead: `-> i32`
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_078_reject_dropped_carried_obligation/input.kz:31:1
|
31 | ~tor spin { h: *Handle<!owned> }
| ^ Code
// NEGATIVE: a label-fold (#loop) carries an OWNED obligation across the back-edge,
// but one branch path neither re-issues nor disposes it -> the obligation is
// DROPPED (leak). Linearity requires every consume of <!owned> to be matched by
// an issue <owned!> or a disposal; the `stop` branch here returns a void event
// payload, silently dropping the consumed handle.
// Grammar grounded against 330_072_obligation_transfer_through_loop (transfer
// shape) and 210_123_label_on_subflow_rhs_panics (#loop / @loop fold form).
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;
}
// Consumes the carried handle. `again` re-issues (linearity OK on that edge),
// but `stop` drops it: a void branch with no <owned!> output and no disposal.
~tor step { h: *Handle<!owned> }
| again *Handle<owned!>
| stop i32
~proc step|zig {
h.n += 1;
if (h.n < 3) {
return .{ .again = h };
}
return .{ .stop = h.n };
}
~tor spin { h: *Handle<!owned> }
| finished i32
~tor report { n: i32 }
~proc report|zig {
std.debug.print("n={}\n", .{n});
}
~spin = #loop step(h)
| again v |> @loop(h: v)
| stop r => finished r // carried obligation never discharged on this path -> leak
~make(): h0 |> spin(h: h0)
| finished f |> report(n: f)
Backend must reject with:
CONTAINS error[KORU030]
CONTAINS was not dischargedFlows
subflow ~spin click a branch to expand · @labels scroll to their anchor
#loop step (h)
flow ~make click a branch to expand · @labels scroll to their anchor
make