✓
Passing Passing: the compiler rejects this program as expected.
Code
// Discharging an OUTER-scope obligation inside a `! each` scope boundary is
// refused at the ARM that discharges it — `! each _ |> app/fs:close(file: f)`
// — not at the flow head. The arm owns the error.
import std/control
import app/fs
app/fs:open(path: "outer.txt"): f |> for(0..3)
! each _ |> app/fs:close(file: f)
| done |> _
Supporting Files
const std = @import("std");
const File = struct { handle: i32 };
~pub tor open { path: string } -> *File<opened!>
~proc open|zig {
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return f;
}
~pub tor close { file: *File<!opened> }
~proc close|zig {
std.heap.page_allocator.destroy(file);
}
~pub tor use-file { file: *File<opened> }
~proc use-file|zig {
std.debug.print("Using file {d}\n", .{file.handle});
}
~pub tor write { file: *File<opened>, data: string }
| written
| err string
~proc write|zig {
std.debug.print("Writing: {s}\n", .{data});
return .{ .written = .{} };
}
Actual compiler output
error[KORU032]: Cannot discharge outer-scope resource 'f' inside @scope boundary. Handle outside the scope or escape via branch constructor.
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_129_scope_discharge_names_the_arm/input.k:7:4
❌ Compiler coordination error: Auto-discharge failed (multiple disposal options or no disposal event)
(set KORU_BACKEND_TRACE=1 for the backend return trace)Must contain:
KORU032Flows
flow ~open click a branch to expand · @labels scroll to their anchor
open (path: "outer.txt")
Test Configuration
MUST_ERROR