✓
Passing This code compiles and runs correctly.
Code
// Test: an armed kebab-named optional branch (`! ?key-down`) FIRES.
//
// Optional arms bind through a comptime presence test —
// `if (@hasDecl(__H, "<arm>")) __H.<arm> else noop` — while the Handlers
// decl itself is minted kebab→snake (`key_down`). The presence key must
// carry the same mangled name; a raw-spelling key never matches and the
// armed handler is silently replaced by the producer-side noop.
//
// The resume-valued `! tick` arm is what lowers this invocation to the
// Handlers_N path (a plain optional-arm-only call splices inline, where
// the bug cannot surface).
//
// Surfaced by koru-libs/metal: `! ?key-down` / `! ?mouse-down` reached
// the ObjC IMP and the mailbox, then died on the noop alias.
import std/io
import std/store
import lib/pump
std/store:new(s) { v: 0[i64] }
tor produce {}
| ok i64
| err string
proc produce|zig { return .{ .ok = 3 }; }
produce()
| ok n |> lib/pump:pump(n)
! tick i |> std/store:stored { s.v: s.v + i } -> i
! key-down k |> std/io:print.ln("hit {{ k:d }}")
| done |> std/io:print.ln("v {{ s.v:d }}")
| err e |> std/io:print.ln("err {{ e:s }}")
Supporting Files
// Cross-module arm-firer: a resume-valued `! tick` arm (forces the
// Handlers_N lowering) plus a kebab-named optional `! ?key-down` arm.
// The |zig proc fires both through the emitted aliases — `key_down`
// arrives at the caller's arm only if the presence key matches the
// mangled decl name.
~pub tor pump { n: i64 }
! tick i64 -> i64
! ?key-down i64
| done
~proc pump|zig {
var acc: i64 = 0;
var i: i64 = 0;
while (i < n) : (i += 1) acc += tick(i);
key_down(9);
return .{ .done = .{} };
}
Actual
hit 9
v 3
Expected output
hit 9
v 3
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (s, source: v: 0[i64])
flow ~produce click a branch to expand · @labels scroll to their anchor
produce
Test Configuration
MUST_RUN
koru.json:
{
"name": "optional-kebab-arm-noop",
"version": "0.1.0",
"paths": {
"std": "../../../../../koru_std",
"app": "{{ ENTRY }}",
"lib": "{{ ENTRY }}/test_lib"
}
}