✓
Passing This code compiles and runs correctly.
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)
Must contain:
error[KORU030]Flows
flow ~gc-alloc click a branch to expand · @labels scroll to their anchor
gc-alloc
Imported 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;
}