✓
Passing This code compiles and runs correctly.
Code
~import app/fs
~app/fs:open(path: "test.txt")
| opened f |> app/fs:read(f.file)
| data d |> app/fs:close(d.file)
Must contain:
Phantom state mismatchError Verification
Expected Error Pattern
KORU030Actual Compiler Output ✓ Pattern matched
error[KORU033]: Cannot issue obligation '<opened!>' on input parameter (event: read). Use '<!opened>' to consume an existing obligation, or remove the '!' suffix.
--> phantom_semantic_check:22:0
error[KORU030]: Phantom state mismatch: argument 'file' has no tracked phantom state, but event requires '<opened!>'. The value must be in state 'app.fs:opened!'.
--> 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_040_undisposed_nested_obligation/backend.zig:94:13: 0x102a6738b in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_040_undisposed_nested_obligation/backend.zig:190:28: 0x102a68077 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
// Library module: fs with nested obligations
// Tests that nested obligations are tracked correctly
const std = @import("std");
const File = struct { handle: i32 };
const Data = struct { content: []const u8 };
// Open a file - returns opened! state
~pub event open { path: []const u8 }
| opened *File<opened!>
~proc open|zig {
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = f };
}
// Read - returns data! state (nested obligation)
~pub event read { file: *File<opened!> }
| data { file: *File<opened!>, content: *Data<data!> }
~proc read|zig {
const d = std.heap.page_allocator.create(Data) catch unreachable;
d.* = Data{ .content = "test content" };
return .{ .data = .{ .file = file, .content = d } };
}
// Close file - consumes opened!
~pub event close { file: *File<!opened> }
~proc close|zig {
std.heap.page_allocator.destroy(file);
}
// Free data - consumes data!
~pub event free { content: *Data<!data> }
~proc free|zig {
std.heap.page_allocator.destroy(content);
}
Test Configuration
MUST_FAIL