✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// Test 210_085: MUST_FAIL — required effect branch covered only by a
// `when`-guarded handler is incomplete coverage.
//
// Symmetric with 210_084. The producer fires `! tick(i)` 0-or-more times;
// each fire dispatches through the consumer's handler. With only a
// `when`-guarded handler (`! tick i when i > 0 |> _`), fires where the
// guard is false (`i == 0`) silently produce no work. That's a coverage
// hole.
//
// Same rule as terminals: required `!` branch with only guarded handlers
// is incomplete. Rescue by an unguarded sibling or by an engaging
// metatype catch-all (`!? Transition t |> ...`).
//
// Note: for OPTIONAL effect branches the rule does NOT apply (see 210_086)
// because the contract already permits no-handler trajectories.
//
// Expected: validator rejects the flow because `! tick` is required but
// only covered by a guarded handler.
// ============================================================================
~pub event ticker { n: usize }
! tick usize
| done usize
~proc ticker|zig {
var i: usize = 0;
while (i < n) : (i += 1) {
tick(i);
}
return .{ .done = i };
}
~ticker(n: 3)
! tick i when i > 0 |> _
| done _ |> _
Must fail at runtime:
Program must error when executed.
Test Configuration
Expected Error:
branch 'tick' must be handled