✓
Passing This code compiles and runs correctly.
Code
// TEST: Auto-discharge with no consumer - MUST FAIL
// STATUS: PENDING IMPLEMENTATION
// MUST_FAIL: No disposal event found
//
// When no event consumes the obligation [!state], the compiler
// cannot auto-discharge and should error clearly.
//
// Here: open() returns *File[opened!] but NO event has [!opened]
// Compiler should error: "No disposal event found for [opened!]"
//
// This indicates a library bug - the library author forgot to
// provide a disposal event for the resource.
~import "$app/fs"
// This should FAIL - no way to dispose!
~app.fs:open(path: "test.txt")
| opened _ |> _
pub fn main() void {}
Imported Files
// Library module: fs
// NO disposal event defined - should error
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 } };
}
// Oops! No close() or any event with [!opened] defined!
// This is a library bug - no way to satisfy the obligation
Test Configuration
MUST_FAIL
Expected Error:
No disposal event found