✓
Passing This code compiles and runs correctly.
Code
// Test: Interpreter binding reference evaluation in args
//
// This tests that when we chain events like:
// first() | ok x |> second(arg: x.field)
//
// The interpreter evaluates x.field against the environment,
// NOT passing the literal string "x.field".
~import std/runtime
~import std/interpreter
~import std/io
const std = @import("std");
// Event that produces a value. Two branches: a lone payload branch is a bare
// return by ruling, and the interpreted chain below needs the branch name.
~pub tor produce {}
| value string
| empty
~produce => value "42"
// Event that consumes a value and echoes it
~pub tor consume { n: string }
| echoed string
| dropped
~proc consume|zig {
std.debug.print("[consume] received n = '{s}'\n", .{n});
return .{ .echoed = n };
}
~std/runtime:register(scope: "test") {
produce
consume
}
// The flow we'll interpret:
// produce() | value v |> consume(n: v)
//
// consume must receive "42" (the bound value evaluated against the
// environment), never the literal text "v". Field access on a scalar payload
// (v.num) is pinned separately by 430_037.
const TEST_FLOW =
\\produce()
\\| value v |> consume(n: v)
;
~std/interpreter:run(source: TEST_FLOW, dispatcher: dispatch_test)
| result r |> std/io:print.ln("Result: {{ r.value.branch:s }}")
| exhausted e |> std/io:print.ln("Exhausted: {{ e.last_event:s }}")
| parse-error e |> std/io:print.ln("Parse error: {{ e.message:s }}")
| validation-error e |> std/io:print.ln("Validation error: {{ e:s }}")
| dispatch-error e |> std/io:print.ln("Dispatch error: {{ e.message:s }}")
Actual
[consume] received n = '42'
Result: echoed
Expected output
[consume] received n = '42'
Result: echoed
Flows
flow ~register click a branch to expand · @labels scroll to their anchor
register (scope: "test", source: produce
consume)
flow ~run click a branch to expand · @labels scroll to their anchor
run (source: TEST_FLOW, dispatcher: dispatch_test)
Test Configuration
MUST_RUN