✗
Failing This test is currently failing.
Failed: backend-exec
Failure Output
Showing last 10 of 11 lines
--> tests/regression/400_RUNTIME_FEATURES/400_147_effect_subflow_optional_when_presence/input.k:30:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/400_147_effect_subflow_optional_when_presence/backend.zig:95:13: 0x10462b9d3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/400_147_effect_subflow_optional_when_presence/backend.zig:202:28: 0x10462cb63 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^ Code
// OPTIONAL ARMS, presence in `when`-guard position — designed 2026-07-03.
// The presence expression is the SAME expression kind in both homes: an
// `if(...)` condition (400_146) and a `when` guard (this test). Here the
// generator's impl guards its `note(i)` fire on the consumer having
// installed the optional handler — `when note` reads "when someone is
// listening" — and skips evaluating the payload entirely when nobody is.
//
// RULED 2026-07-03: a presence guard counts as FULL coverage of the
// upstream branch, required or not — NO unguarded fallback sibling is
// needed. The 210_084/085 when-only rejection targets RUNTIME value guards,
// which drop an unpredictable subset of firings (a silent per-firing hole).
// A presence guard is COMPTIME: per consumer it is all-or-nothing,
// statically known, visible in source — and its false case ("nobody
// installed `note`") is exactly the trajectory the `?` on the arm already
// blesses. Forcing a fallback here would demand a branch whose entire
// content is the no-op the optional contract already implies.
//
// This consumer DOES install `note`, so every firing lands on the guard.
import std/io
import std/control
pub event gen { n: usize }
! ?note usize
| done usize
gen = for(0..n)
! each i when note |> note(i)
| done => done n
gen(n: 3)
! note i |> std/io:print.ln("note {{ i:d }}")
| done n |> std/io:print.ln("{{ n:d }}")
Expected output
note 0
note 1
note 2
3
Flows
subflow ~gen click a branch to expand · @labels scroll to their anchor
for (0..n)
flow ~gen click a branch to expand · @labels scroll to their anchor
gen (n: 3)
Test Configuration
MUST_RUN