○
Planned This feature is planned but not yet implemented.
TODO: Auto-dispose doesn't trigger before void event invocations
Code
// TEST: Auto-discharge with void event chaining
//
// A void event has no branches - the flow just continues.
// If we have an obligation and chain to a void event, auto-discharge
// should still insert the disposal.
//
// Expected: Auto-discharge inserts close() before the void event
~import "$app/fs"
// Void event - no branches, just side effect
~event log_done {}
~proc log_done {
std.debug.print("Done!\n", .{});
}
const std = @import("std");
// Open file, then chain to void event - obligation should be auto-discharged
~app.fs:open(path: "test.txt")
| opened _ |> log_done()
pub fn main() void {}
Expected Output
Opening file: test.txt
Closing file (auto-discharged)
Done!
Imported Files
const std = @import("std");
const File = struct { handle: i32 };
~pub event open { path: []const u8 }
| opened { file: *File[opened!] }
~proc open {
std.debug.print("Opening file: {s}\n", .{path});
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = .{ .file = f } };
}
~pub event close { file: *File[!opened] }
| closed {}
~proc close {
std.debug.print("Closing file (auto-discharged)\n", .{});
return .{ .closed = .{} };
}