✓
Passing Passing: the compiler rejects this program as expected.
Code
import app/fs
app/fs:open(path: "test.txt"): f |> app/fs:close(file: f) |> app/fs:use-file(file: f) // ERROR: f was disposed!
Supporting Files
const std = @import("std");
const File = struct { handle: i32 };
~pub tor open { path: string } -> *File<opened!>
~proc open|zig {
std.debug.print("Opening file: {s}\n", .{path});
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return f;
}
~pub tor close { file: *File<!opened> } // Consumes obligation
~proc close|zig {
std.debug.print("Closing file\n", .{});
}
~pub tor use-file { file: *File<opened> } // Expects opened file
~proc use-file|zig {
std.debug.print("Using file\n", .{});
}
Actual compiler output
error[KORU030]: Use-after-discharge: binding 'f' was already discharged and cannot be used
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_007_use_after_disposal/input.k:2:0
❌ Compiler coordination error: Phantom semantic validation failed
(set KORU_BACKEND_TRACE=1 for the backend return trace)Must contain:
Use-after-dischargeFlows
flow ~open click a branch to expand · @labels scroll to their anchor
open (path: "test.txt")
Test Configuration
MUST_ERROR