✓
Passing This code compiles and runs correctly.
Code
// Test: `when` guard on an `!` effect-branch handler with struct payload,
// guarding on a field access. This is the canonical vaxis-shaped TUI
// dispatch: handle only key events matching a specific character.
//
// The producer fires `! key { ch, code }` for several characters. The
// consumer guards on `k.ch == 'q'` to dispatch only the quit key.
// Other keys fall through the guard and drop silently — there is no
// catch-all to write for them. Here we pin that:
// 1. `when` works on struct-payload bindings, not just identity.
// 2. Field access in the guard (`k.ch`) parses and lowers correctly.
// 3. Unmatched fires are silently dropped (no handler runs) — the
// consumer doesn't need to write a sibling handler for the false
// case of the guard.
//
// Expected output: only the 'q' key fires the handler.
//
// (220_034 ruling: the former `! key _ |> _` sibling was removed — a
// discard on an already-handled effect is KORU039; unmatched fires need
// no discard.)
~import std/io
~pub tor keystream { count: usize }
! key { ch: u8, code: u8 }
~proc keystream|zig {
const chars = [_]u8{ 'a', 'b', 'q', 'c' };
var i: usize = 0;
while (i < count and i < chars.len) : (i += 1) {
key(.{ .ch = chars[i], .code = chars[i] });
}
}
~keystream(count: 4)
! key k when k.ch == 'q' |> std/io:print.blk {
quit pressed
}
Actual
quit pressed
Expected output
quit pressed
Flows
flow ~keystream click a branch to expand · @labels scroll to their anchor
keystream (count: 4)
Test Configuration
MUST_RUN