✓
Passing This code compiles and runs correctly.
Code
// REQUIREMENT (effect-branch obligations, resume-issue FORBIDDEN — the mirror
// of 400_104): a `!` branch fires 0-to-N times. A resume type that ISSUES an
// obligation (`-> *R<state!>`) would hand the proc a fresh obligation per
// firing that escapes the firing un-discharged — incoherent. Must be rejected
// at the SIGNATURE level (NOT by inspecting any body). Symmetric to payload
// rules: resume-DISCHARGE (`-> *R<!state>`, 400_106) IS coherent (cleaned up
// in-scope, handed back); only resume-ISSUE is forbidden.
const std = @import("std");
const Resource = struct { id: usize };
var global_r = Resource{ .id = 99 };
~pub event borrow { n: usize }
! lend usize -> *Resource<active!>
| done usize
~proc borrow|zig {
for (0..n) |i| {
const r = lend(i);
std.debug.print("got {}\n", .{r.id});
}
return .{ .done = n };
}
Frontend must reject with:
CONTAINS error[KORU027]
CONTAINS cannot issue an obligationError Verification
Actual Compiler Output
error[KORU027]: effect branch resume type cannot issue an obligation
--> tests/regression/400_RUNTIME_FEATURES/400_107_effect_resume_cannot_issue_obligation/input.kz:13:27
|
13 | ! lend usize -> *Resource<active!>
| ^
hint: a `!` effect branch fires 0-to-N times, so resuming `<active!>` (issue) would let the obligation escape un-discharged — drop the trailing `!`, or discharge in-scope with `<!active>`Test Configuration
MUST_FAIL