002 explicit plus catchall

✓ Passing This code compiles and runs correctly.

Code

// Test 918b: Optional Branches - Mix Explicit Handling + |? Catch-All
//
// Verifies:
// 1. Handler explicitly handles SOME optional branches
// 2. |? catches remaining optional branches
// 3. Most realistic real-world pattern

~import "$std/io"

// Event with required + multiple optional branches
// success is REQUIRED, warning is handled explicitly, debug/trace caught by |?
~event process { value: u32 }
| success u32
| ?warning []const u8
| ?debug []const u8
| ?trace []const u8

~proc process {
    if (value > 100) {
        return .{ .warning = "Value too large" };
    }
    if (value % 2 == 1) {
        return .{ .debug = "Value is odd" };
    }
    if (value < 5) {
        return .{ .trace = "Very small value" };
    }
    return .{ .success = value * 2 };
}

// value=10 → success (required, handled)
~process(value: 10)
| success _ |> std.io:print.ln("SUCCESS")
| warning _ |> std.io:print.ln("WARNING")
|? |> std.io:print.ln("OPTIONAL CAUGHT")

// value=150 → warning (optional, handled explicitly)
~process(value: 150)
| success _ |> std.io:print.ln("SUCCESS")
| warning _ |> std.io:print.ln("WARNING")
|? |> std.io:print.ln("OPTIONAL CAUGHT")

// value=7 → debug (optional, caught by |?)
~process(value: 7)
| success _ |> std.io:print.ln("SUCCESS")
| warning _ |> std.io:print.ln("WARNING")
|? |> std.io:print.ln("OPTIONAL CAUGHT")

// value=2 → trace (optional, caught by |?)
~process(value: 2)
| success _ |> std.io:print.ln("SUCCESS")
| warning _ |> std.io:print.ln("WARNING")
|? |> std.io:print.ln("OPTIONAL CAUGHT")
input.kz

Expected

SUCCESS
WARNING
OPTIONAL CAUGHT
OPTIONAL CAUGHT

Actual

SUCCESS
WARNING
OPTIONAL CAUGHT
OPTIONAL CAUGHT

Test Configuration

MUST_RUN