✓
Passing This code compiles and runs correctly.
Code
~import app/fs
~app/fs:open(path: "test.txt")
| opened f |> app/fs:close(file: f) |> app/fs:use-file(file: f) // ERROR: f was disposed!
Must contain:
Use-after-dischargeError Verification
Expected Error Pattern
Backend should fail - no disposal event available or multiple disposal optionsActual Compiler Output
error[KORU030]: Use-after-discharge: binding 'f' was already discharged and cannot be used
--> phantom_semantic_check:3:0
❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_007_use_after_disposal/backend.zig:94:13: 0x100fb338b in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_007_use_after_disposal/backend.zig:190:28: 0x100fb4077 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
const std = @import("std");
const File = struct { handle: i32 };
~pub event open { path: []const u8 }
| opened *File<opened!>
~proc open|zig {
std.debug.print("Opening file: {s}\n", .{path});
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = f };
}
~pub event close { file: *File<!opened> } // Consumes obligation
~proc close|zig {
std.debug.print("Closing file\n", .{});
}
~pub event use-file { file: *File<opened> } // Expects opened file
~proc use-file|zig {
std.debug.print("Using file\n", .{});
}
Test Configuration
MUST_FAIL