002 inline flow branches

✓ Passing This code compiles and runs correctly.

Code

// Test 108: Inline Flow with Multiple Branches
// Tests that inline flows can handle multiple branch paths
const std = @import("std");

~event validate { value: i32 }
| success { validated: i32 }
| error { code: i32 }

~proc validate {
    if (value > 0) {
        return .{ .success = .{ .validated = value } };
    } else {
        return .{ .@"error" = .{ .code = -1 } };
    }
}

~event process { input: i32 }
| ok { result: i32 }
| failed {}

// Inline flow with branch handling
~proc process = validate(value: input)
| success s |> ok { result: s.validated * 2 }
| error e |> failed {}

~event main {}
~proc main {
    const result1 = process_event.handler(.{ .input = 10 });
    std.debug.print("Success result: {}\n", .{result1.ok.result});

    const result2 = process_event.handler(.{ .input = -5 });
    _ = result2;
    std.debug.print("Failed\n", .{});
}

~main()
input.kz

Expected Output

Success result: 20
Failed

Test Configuration

MUST_RUN