✓
Passing This code compiles and runs correctly.
Code
// Pins that `path(args)|variant` on a [comptime|norun] decl is declaration
// metadata, not proc dispatch: no `proc tag|dev` exists, so the emitted
// comptime_flowN must call the BASE `handler` — `handler__dev` does not exist
// on the event struct. The command handler reads the variant back off the
// AST to prove the tag survives for collectors (stack's `service(db)|dev`).
//
// Run: koruc input.kz seen → variant=dev, then ok
~import std/compiler
~[comptime|norun]tor tag {
name: string,
}
~proc tag|zig {
}
~tag(name: "first")
~tag(name: "second")|dev
~std/compiler:command.declare {
"name": "seen",
"description": "Print the variant tag carried by each tag decl"
}
~[comptime|command]pub tor seen {
program: *const Program,
allocator: __koru_std.mem.Allocator,
argv: []string,
}
const std = @import("std");
~proc seen|zig {
for (program.items) |*item| {
if (item.* == .flow) {
const f = &item.flow;
if (f.inv().path.segments.len == 1 and
std.mem.eql(u8, f.inv().path.segments[0], "tag"))
{
if (f.inv().variant) |v| {
std.debug.print("variant={s}\n", .{v});
}
}
}
}
std.debug.print("ok\n", .{});
}
~tor main {}
~proc main|zig {
}
~main()
Flows
flow ~tag click a branch to expand · @labels scroll to their anchor
tag (name: "first")
flow ~tag click a branch to expand · @labels scroll to their anchor
tag|dev (name: "second")
flow ~command.declare click a branch to expand · @labels scroll to their anchor
command.declare (source: "name": "seen",
"description": "Print the variant tag carried by each tag decl")
flow ~main click a branch to expand · @labels scroll to their anchor
main
Test Configuration
Post-validation Script:
#!/bin/bash
# The backend must compile: before the fix the comptime_flowN for
# `tag(second)|dev` emitted `tag_event.handler__dev(...)`, a member that does
# not exist because no `proc tag|dev` was declared. The handler also prints
# the variant back off the AST — the tag must survive as collector metadata.
set -e
OUT=$(koruc "$KORU_INPUT" seen 2>&1)
echo "$OUT" | grep -q "variant=dev" || { echo "FAIL: variant metadata lost"; echo "$OUT"; exit 1; }
echo "$OUT" | grep -q "ok" || { echo "FAIL: command did not run"; echo "$OUT"; exit 1; }
echo "PASS"