✓
Passing This code compiles and runs correctly.
Code
// 696_008 — a recursive tor under a ctx scope: the clone's recursive call
// hits the SAME specialization key, so `countdown__ctx_inner` dispatches
// to itself — specialization terminates instead of generating clones
// forever.
import std/io
import std/store
import std/ctx
std/store:new(inner) { a: 9[i64] }
pub tor ctxprobe { a: i64 }
ctxprobe = std/io:print.ln("ctxprobe a={{ a:d }}")
pub tor countdown { n: i64 }
countdown = if(n == 0)
| then |> std/io:print.ln("done")
| else |> ctxprobe() |> countdown(n: n - 1)
std/io:print.ln("seed")
|> std/ctx(inner) |> countdown(n: 2)
Actual
seed
ctxprobe a=9
ctxprobe a=9
done
Expected output
seed
ctxprobe a=9
ctxprobe a=9
done
Flows
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 }}")
subflow ~countdown click a branch to expand · @labels scroll to their anchor
if (n == 0)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "seed")
Test Configuration
MUST_RUN LANGUAGES: zig