✓
Passing This code compiles and runs correctly.
Code
~import "$app/lib/fs"
~import "$app/lib/mipmap"
const std = @import("std");
const File = struct {
handle: i32,
};
~event needs_fs_file { file: *File[app.lib.fs:open] }
~proc needs_fs_file {
}
~app.lib.mipmap:load(path: "texture.png")
| loaded m |> needs_fs_file(file: m)
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[open]
~proc open {
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = 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[open]
~proc load {
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .loaded = f };
}
Test Configuration
Expected Error:
Phantom state mismatch