✓
Passing This code compiles and runs correctly.
Code
~import "$std/io"
~import "$app/fileops"
const std = @import("std");
const File = struct {
handle: i32,
};
~app.fileops:open(path: "test.txt")
| opened f |> app.fileops:close(file: f) |> std.io:println(text: "File closed successfully")
Expected
Opening file: test.txt
Closing file
File closed successfully
Actual
Opening file: test.txt
Closing file
File closed successfully
Imported Files
// Library module: fileops
// Defines file operations with phantom type states
const std = @import("std");
// File type with phantom states
const File = struct {
handle: i32,
};
// Open a file - returns opened state
~pub event open { path: []const u8 }
| opened *File[open]
~proc open {
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 .{ .opened = f };
}
// Close a file - accepts open state, returns closed state
~pub event close { file: *File[open] }
~proc close {
std.debug.print("Closing file\n", .{});
}
Test Configuration
MUST_RUN