✓
Passing Passing: the compiler rejects this program as expected.
Code
// PIN: passing a value whose phantom state does not match the callee's
// required state is refused — open-file issues <open>, close-file requires
// <closed>, so the call must not compile.
const std = @import("std");
~tor open-file {} -> *std.fs.File<open>
~proc open-file|zig {
const allocator = std.heap.page_allocator;
const f = allocator.create(std.fs.File) catch unreachable;
return f;
}
~tor close-file { file: *std.fs.File<closed> }
~proc close-file|zig {
}
~open-file(): o |> close-file(file: o)
Actual compiler output
error[KORU030]: Phantom state mismatch: expected 'input:closed' but got 'input:open' for argument 'file'
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/909_phantom_state_mismatch/input.kz:14:1Must contain:
error[KORU030]Flows
flow ~open-file click a branch to expand · @labels scroll to their anchor
open-file
Test Configuration
MUST_ERROR