✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// Test 065: Optional Branches Are Truly Optional
// Tests that optional branches can be COMPLETELY IGNORED (no |? catch-all needed)
// This is the killer feature - they're truly optional!
// ============================================================================
const std = @import("std");
// Event with required and optional branches
// success: REQUIRED - must be handled
// warning, debug: OPTIONAL - can be ignored!
~event process { value: u32 }
| success u32
| ?warning []const u8
| ?debug []const u8
// Proc that can return any branch
~proc process {
if (value > 100) {
return .{ .warning = @as([]const u8, "Large value") };
}
if (value % 2 == 1) {
return .{ .debug = @as([]const u8, "Odd value") };
}
std.debug.print("Success: {}\n", .{value * 2});
return .{ .success = value * 2 };
}
// Flow that ONLY handles required branch - optional branches are ignored!
// This should compile and run - warning/debug branches are silently ignored
~process(value: 10)
| success _ |> _
// NO |? catch-all needed!
// NO | warning w |> needed!
// NO | debug d |> needed!
// They're truly optional - silent no-op if they fire!
Test Configuration
Expected Behavior:
COMPILE_ONLY