✓
Passing This code compiles and runs correctly.
Code
// codemod:skip — runtime-eval blocks use internal (snake) names; flow_parser does not normalize.
// Test: std/runtime:eval invokes auto-discharge cleanup events
~import std/runtime
~import std/io
const std = @import("std");
~pub event open-handle {}
| opened []const u8<opened!>
~proc open-handle|zig {
std.debug.print("OPEN\n", .{});
return .{ .opened = "h1" };
}
~pub event close-handle { handle: []const u8<!opened> }
~proc close-handle|zig {
std.debug.print("CLOSE\n", .{});
}
~std/runtime:register(scope: "api") {
open-handle(1)
close-handle(1)
}
const TEST_SOURCE = "~open-handle()";
~std/runtime:parse.source(source: TEST_SOURCE, file-name: "runtime_eval_autodischarge.kz", allocator: std.heap.page_allocator)
| parsed p |> std/runtime:eval(ast: p, scope: "api")
| result _ |> std/io:print.ln("OK")
| exhausted _ |> std/io:print.ln("EXHAUSTED")
| validation-error _ |> std/io:print.ln("VALIDATION ERROR")
| event-denied _ |> std/io:print.ln("EVENT DENIED")
| dispatch-error _ |> std/io:print.ln("DISPATCH ERROR")
| scope-not-found _ |> std/io:print.ln("SCOPE NOT FOUND")
| parse-error _ |> std/io:print.ln("PARSE ERROR")
Actual
[EVAL] Starting execution of pre-parsed flow
[EVAL] Validation passed
OPEN
[EVAL] Execution complete, branch: opened
CLOSE
[AUTO-DISCHARGE] Invoked 'close-handle' for handle 'h1' [main:opened]
OK
Expected output
[EVAL] Starting execution of pre-parsed flow
[EVAL] Validation passed
OPEN
[EVAL] Execution complete, branch: opened
CLOSE
[AUTO-DISCHARGE] Invoked 'close-handle' for handle 'h1' [main:opened]
OK
Test Configuration
MUST_RUN