✓
Passing This code compiles and runs correctly.
Code
// 696_001 — std/ctx: lexical scope injection via the bare-attach default tor.
//
// PINS the scope-stack semantics: `std/ctx(X)` is a compile-time scope over
// its continuation subtree; every invocation inside gets unfilled params
// injected from the nearest enclosing scope whose named store provides a
// field of that name.
// explicit arg > innermost ctx > outward ctx > declared default > refusal
// The ctx step splices out at comptime — the emitted call reads store cells
// directly; nothing resolves at run. ctxprobe is a probe tor declared in
// this file that prints the params it received; the feature under test is
// the injection, not the probe.
import std/io
import std/store
import std/ctx
std/store:new(outer) { a: 1[i64], b: 2[i64], c: 3[i64] }
std/store:new(inner) { a: 9[i64] }
pub tor ctxprobe { a: i64, b: i64, c: i64 }
ctxprobe = std/io:print.ln("ctxprobe a={{ a:d }} b={{ b:d }} c={{ c:d }}")
std/io:print.ln("seed")
|> std/ctx(outer) |> ctxprobe()
|> std/ctx(inner) |> ctxprobe()
|> ctxprobe(b: 42)
Actual
seed
ctxprobe a=1 b=2 c=3
ctxprobe a=9 b=2 c=3
ctxprobe a=9 b=42 c=3
Expected output
seed
ctxprobe a=1 b=2 c=3
ctxprobe a=9 b=2 c=3
ctxprobe a=9 b=42 c=3
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (outer, source: a: 1[i64], b: 2[i64], c: 3[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (inner, source: a: 9[i64])
subflow ~ctxprobe click a branch to expand · @labels scroll to their anchor
print.ln (expr: "ctxprobe a={{ a:d }} b={{ b:d }} c={{ c:d }}")
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "seed")
Test Configuration
MUST_RUN LANGUAGES: zig