○
Planned This feature is planned but not yet implemented.
Auto-dispose for obligations in @loop branches not implemented
Failure Output
error[KORU100]: unused binding 'f'
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_017_scope_label_loop/input.kz:33:4
|
33 | | opened f |> @loop(count: n.count) // Auto-close f before @loop
| ^
hint: remove the binding if not needed Code
~import app/fs
const std = @import("std");
~event iterate { count: i32 }
| next i32
~proc iterate|zig {
if (count < 3) {
return .{ .next = count + 1 };
} else {
}
}
~#loop iterate(count: 0)
| next n |> app/fs:open(path: "test.txt")
| opened f |> @loop(n.count) // Auto-close f before @loop
|> _
Expected output
Opening file
Closing file
Opening file
Closing file
Opening file
Closing file
Imported Files
// Library module: fs
// Single disposal event
const std = @import("std");
const File = struct { handle: i32 };
// Open a file - returns opened! state (requires cleanup)
~pub event open { path: []const u8 }
| opened *File<opened!>
~proc open|zig {
std.debug.print("Opening file\n", .{});
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = f };
}
// Close - the ONLY consumer of [!opened]
~pub event close { file: *File<!opened> }
~proc close|zig {
std.debug.print("Closing file\n", .{});
}
Test Configuration
MUST_RUN