✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// VERIFIED REGRESSION TEST - DO NOT MODIFY WITHOUT DISCUSSION
// ============================================================================
// Test: Phantom state mismatch detection
// Tests that phantom checker detects incompatible cross-module phantom states
// Expected: MUST_FAIL with KORU030 (phantom state mismatch)
~import "$app/lib/fs"
~import "$app/lib/mipmap"
const std = @import("std");
const File = struct {
handle: i32,
};
// Event that expects app.lib.fs:open phantom state
~event needs_fs_file { file: *File[app.lib.fs:open] }
| processed {}
~proc needs_fs_file {
return .{ .processed = .{} };
}
// This should FAIL: mipmap:open ≠ fs:open
~app.lib.mipmap:load(path: "texture.png")
| loaded m |> needs_fs_file(file: m.file)
| processed |> _
Imported Files
// File system module with phantom state
const std = @import("std");
const File = struct {
handle: i32,
};
// Opens a file, returns with fs:open phantom state
~pub event open { path: []const u8 }
| opened { file: *File[open] }
~proc open {
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = .{ .file = f } };
}
// Mipmap module with its own phantom state
const std = @import("std");
const File = struct {
handle: i32,
};
// Loads a mipmap, returns with mipmap:open phantom state
~pub event load { path: []const u8 }
| loaded { file: *File[open] }
~proc load {
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .loaded = .{ .file = f } };
}
Test Configuration
Expected Error:
Phantom state mismatch