✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS: a state VARIABLE constraint is checked against the concrete state.
// `process` accepts `*Data<M'owned|borrowed>`; `gc-alloc` hands back
// `*Data<gc>`, which is neither member, so the call is refused and the
// diagnostic names both the constraint and the state that failed it.
~import app/data
~app/data:gc-alloc(): a |> app/data:process(d: a)
Supporting Files
const std = @import("std");
const Data = struct { value: i32 };
~pub tor gc-alloc {} -> *Data<gc> // GC-managed, NOT owned or borrowed
~proc gc-alloc|zig {
const allocator = std.heap.page_allocator;
const d = allocator.create(Data) catch unreachable;
d.* = Data{ .value = 42 };
return d;
}
// Generic processor constrained to owned OR borrowed ONLY
~pub tor process { d: *Data<M'owned|borrowed> } -> *Data<M'owned|borrowed>
~proc process|zig {
return d;
}
// Generic processor constrained to owned OR borrowed ONLY
~pub tor process { data: *Data<M'owned|borrowed> } -> *Data<M'owned|borrowed>
~proc process|zig {
return data;
}
Actual compiler output
error[KORU030]: Phantom state mismatch: expected 'M'owned|borrowed' but got 'app.data:gc' for argument 'd'
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/524_state_variable_constraint_violation/input.kz:6:0
❌ Compiler coordination error: Phantom semantic validation failed
(set KORU_BACKEND_TRACE=1 for the backend return trace)Must contain:
error[KORU030]Flows
flow ~gc-alloc click a branch to expand · @labels scroll to their anchor
gc-alloc
Test Configuration
MUST_ERROR