✓
Passing This code compiles and runs correctly.
Code
// Negative test: consumer must handle every non-optional terminal of an
// event. The `?` modifier on a terminal (`| ?done`) marks it as optional
// — consumer may omit; the compiler synthesizes a no-op switch arm. Without
// the `?`, the terminal is required, and omitting the handler must error.
//
// The event below declares `| done` (required) and `| err []const u8`
// (required). The consumer's flow handles `| err` but NOT `| done`. The
// compiler must reject this — silent auto-synthesis of the missing arm
// would mean `?` carries no meaning and the language has no way to
// distinguish "optional terminal" from "you forgot a handler".
~import std/io
~pub event run {}
| done
| err []const u8
~proc run|zig {
return .{ .done = .{} };
}
~run()
| err msg |> std/io:print.ln(msg)
Must fail at runtime:
Program must error when executed.
Error Verification
Actual Compiler Output
error[KORU022]: branch 'done' must be handled but no continuation found
--> tests/regression/400_RUNTIME_FEATURES/400_097_required_terminal_must_be_handled/input.kz:23:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/400_097_required_terminal_must_be_handled/backend.zig:94:13: 0x1033f21b7 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/400_097_required_terminal_must_be_handled/backend.zig:190:28: 0x1033f2ea3 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Test Configuration
MUST_FAIL
Expected Error:
KORU022