✓
Passing This code compiles and runs correctly.
Code
// TEST: Auto-dispose with multiple consumers - MUST FAIL
// STATUS: PENDING IMPLEMENTATION
// MUST_FAIL: Multiple disposal options
//
// When multiple events consume the same obligation [!state],
// the compiler cannot auto-choose - user must be explicit.
//
// Here: Both close() and abandon() consume *File[!opened]
// Compiler should error: "Multiple disposal options for [opened!]: close, abandon"
//
// To fix, user would write:
// | opened f |> app.fs:close(file: f.file)
// | closed |> _
// OR:
// | opened f |> app.fs:abandon(file: f.file)
// | abandoned |> _
~import "$app/fs"
// This should FAIL - two disposal options, be explicit!
~app.fs:open(path: "test.txt")
| opened _ |> _
pub fn main() void {}
Imported Files
// Library module: fs
// Multiple disposal events - requires explicit choice
const std = @import("std");
const File = struct { handle: i32 };
// Open a file - returns opened! state (requires cleanup)
~pub event open { path: []const u8 }
| opened { file: *File[opened!] }
~proc open {
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = .{ .file = f } };
}
// Close - saves any changes before closing
~pub event close { file: *File[!opened] }
| closed {}
~proc close {
std.debug.print("Closing file (saving changes)\n", .{});
return .{ .closed = .{} };
}
// Abandon - discards any changes
~pub event abandon { file: *File[!opened] }
| abandoned {}
~proc abandon {
std.debug.print("Abandoning file (discarding changes)\n", .{});
return .{ .abandoned = .{} };
}
Test Configuration
MUST_FAIL
Expected Error:
Multiple disposal options