✓
Passing This code compiles and runs correctly.
Code
~import app/resource
~app/resource:risky()
| success _ |> _
Actual
Operation succeeded
Expected output
Operation succeeded
Imported Files
// Library module: resource
// Demonstrates optional branch with obligation
const std = @import("std");
const Handle = struct {
id: i32,
};
// Risky operation - might succeed OR might leak a handle
~pub event risky {}
| success u32
| ?leaked *Handle<owned!> // Optional with obligation!
~proc risky|zig {
// Always succeeds in this test, but the event DECLARES
// that it COULD return ?leaked with an obligation
std.debug.print("Operation succeeded\n", .{});
return .{ .success = 42 };
}
// Disposer for the obligation (would need to be called for ?leaked)
~pub event close { handle: *Handle<!owned> }
~proc close|zig {
std.debug.print("Closing handle\n", .{});
}
Test Configuration
MUST_RUN