✓
Passing This code compiles and runs correctly.
Code
~import "$std/control"
~import "$std/build"
~std.build:requires { exe.linkLibC(); }
const std = @import("std");
const Resource = struct {
id: usize,
};
const allocator = std.heap.c_allocator;
~event create { id: usize }
| created *Resource[active!]
~proc create {
const r = allocator.create(Resource) catch unreachable;
r.* = Resource{ .id = id };
return .{ .created = r };
}
~event use { r: *Resource[active] }
~proc use {
std.debug.print("using {}\n", .{r.id});
}
~for(0..10)
| each i |>
create(id: i)
| created r |>
use(r) // use it, but can't dispose - no destroy event exists!
pub fn main() void {}
Error Verification
Actual Compiler Output
error[KORU030]: Resource 'r' with phantom state [active!] was not disposed.
--> auto_discharge:21:0
❌ Compiler coordination error: Auto-discharge failed (multiple disposal options or no disposal event)
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_053_for_loop_obligation_escape/backend.zig:9447:17: 0x100b524af in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_053_for_loop_obligation_escape/backend.zig:9531:28: 0x100b532b7 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Test Configuration
MUST_FAIL
Expected Behavior:
BACKEND_COMPILE_ERROR