✓
Passing This code compiles and runs correctly.
Code
// This test verifies that the phantom semantic checker reports ALL errors in a single pass
// rather than stopping at the first error
pub const File = struct {
handle: usize,
};
~event open_file { path: []const u8 }
| opened { file: *File[open] }
~event close_file { file: *File[closed] }
| done {}
~event read_file { file: *File[open] }
| done {}
~event write_file { file: *File[open] }
| done {}
~proc open_file {
const f = File{ .handle = 42 };
return .{ .opened = .{ .file = &f } };
}
~proc close_file {
_ = file;
return .{ .done = .{} };
}
~proc read_file {
_ = file;
return .{ .done = .{} };
}
~proc write_file {
_ = file;
return .{ .done = .{} };
}
// Flow 1: ERROR - Passing [open] file to close_file expecting [closed]
~open_file(path: "test1.txt")
| opened o |> close_file(file: o.file)
| done |> _
// Flow 2: ERROR - Passing [open] file to close_file expecting [closed]
~open_file(path: "test2.txt")
| opened o |> close_file(file: o.file)
| done |> _
// Flow 3: ERROR - Passing [open] file to close_file expecting [closed]
~open_file(path: "test3.txt")
| opened o |> close_file(file: o.file)
| done |> _
Error Verification
Expected Error Pattern
This test must fail with phantom state mismatch errors.
All three errors should be reported in a single compilation pass.Actual Compiler Output
[PHASE 2.4] Calling run_pass for transforms\n[PHASE 2.5] Executing comptime_main() - running comptime flows
[PHASE 2.5] Comptime flows complete (34 items)
[PHASE 2.6] Rescanning transformed AST (34 items)
[PHASE 2.6] Rescan complete: 25 comptime events found
[0] std.compiler:requires
[1] std.compiler:flag.declare
[2] std.compiler:command.declare
[3] std.compiler:coordinate
[4] std.compiler:context_create
[5] std.testing:test
[6] std.testing:validate_mocks
[7] std.testing:test.with_harness
[8] std.testing:test.harness
[9] std.testing:assert
[10] std.testing:test.property.equivalent
[11] std.deps:deps
[12] std.deps:requires.system
[13] std.deps:requires.zig
[14] std.control:if
[15] std.control:for
[16] std.control:capture
[17] std.control:const
[18] std.build:requires
[19] std.build:variants
[20] std.build:config
[21] std.build:command.sh
[22] std.build:command.zig
[23] std.build:step
[24] std.template:define
[PHANTOM-KORU] Starting phantom check proc...
error[KORU030]: Phantom state mismatch: expected 'input:closed' but got 'input:open' for argument 'file'
--> phantom_semantic_check:42:0
error[KORU030]: Phantom state mismatch: expected 'input:closed' but got 'input:open' for argument 'file'
--> phantom_semantic_check:47:0
error[KORU030]: Phantom state mismatch: expected 'input:closed' but got 'input:open' for argument 'file'
--> phantom_semantic_check:52:0
❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/920_multiple_errors/backend.zig:9610:17: 0x10495a433 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/920_multiple_errors/backend.zig:9694:28: 0x10495b1bf in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Test Configuration
MUST_FAIL