✓
Passing This code compiles and runs correctly.
Code
// Test 355_004: Optional Branches - Shape Validation Still Applies
//
// Verifies:
// 1. Optional branches are still subject to shape checking
// 2. "Optional" means "can be omitted", NOT "can be misused"
// 3. Handling a nonexistent branch name = compile error
~import std/io
// Event with required + optional branch
~tor process { value: u32 }
| success u32 // REQUIRED
| ?warning string // OPTIONAL
~proc process|zig {
if (value > 100) {
return .{ .warning = "Value too large" };
}
return .{ .success = value * 2 };
}
// Handler references a branch that doesn't exist on this event
// "nonexistent" is not a branch of process — should fail compilation
~process(value: 150)
| success _ |> std/io:print.ln("OK")
| nonexistent _ |> std/io:print.ln("BAD")
Backend must reject with:
CONTAINS error[KORU021]
CONTAINS has no branch 'nonexistent'Flows
flow ~process click a branch to expand · @labels scroll to their anchor
process (value: 150)