✓
Passing This code compiles and runs correctly.
Code
// REQUIREMENT (effect-branch obligations, FORBIDDEN — hard invariant):
// A `!` branch fires 0-to-N times. Declaring that it DISCHARGES an obligation
// (`<!state>` on its payload) is incoherent — that promises "discharge exactly
// once" via a branch that may fire zero or many times. Must be rejected at the
// signature level (NOT a body check). If accepted, the invariant is unenforced.
~import std/build
~std/build:requires { exe.linkLibC(); }
const std = @import("std");
const Resource = struct { id: usize };
// An effect branch whose payload claims to DISCHARGE an outer obligation.
~pub event drain { items: []const *Resource }
! each *Resource<!active>
| done usize
~proc drain|zig {
for (items) |it| { each(it); }
return .{ .done = items.len };
}
pub fn main() void {}
Frontend must reject with:
CONTAINS error[KORU027]
CONTAINS cannot discharge an obligationError Verification
Actual Compiler Output
error[KORU027]: effect branch payload cannot discharge an obligation
--> tests/regression/400_RUNTIME_FEATURES/400_104_effect_branch_cannot_discharge_outer/input.kz:13:18
|
13 | ! each *Resource<!active>
| ^
hint: a `!` effect branch fires 0-to-N times, so `<!active>` (discharge) is incoherent — drop the leading `!` for plain state matching, or issue one obligation per firing with `<active!>`Test Configuration
MUST_FAIL