✓
Passing This code compiles and runs correctly.
Code
// PIN (recursion-unroll pass, challenge 035 leg): effects-bearing recursion
// must REFUSE — silently, unchanged. The body is the eligible fib shape plus
// one `std/io:print.ln` console effect inside the recursive branch. Unrolling
// would duplicate/reorder the effect across substituted body copies, so the
// pass's purity/effect gate must decline it: emitted Zig keeps the baseline
// shape — 2 self-call sites + 1 external = 3 `fibio_event.handler(` calls,
// no parameter-substituted guards. expected.txt records the deterministic
// pre-order "d" lines (one per internal node) plus the result.
import std/io
pub tor fibio { n: i64 } -> i64
fibio = if(n < 2)
| then -> n
| else |> std/io:print.ln("d") |> fibio(n: n - 1): a |> fibio(n: n - 2): b -> a + b
fibio(n: 5): r |> std/io:print.ln("{{ r:d }}")
Actual
d
d
d
d
d
d
d
5
Expected output
d
d
d
d
d
d
d
5
Flows
subflow ~fibio click a branch to expand · @labels scroll to their anchor
if (n < 2)
flow ~fibio click a branch to expand · @labels scroll to their anchor
fibio (n: 5)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: recursion bearing a console effect (std/io:print.ln inside the
# recursive branch) must NOT be unrolled — the emitted shape stays at the
# baseline 3 `fibio_event.handler(` sites (2 self + 1 main) with no
# parameter-substituted guards. Refusal is silent: the program still runs
# and prints correctly (expected.txt).
set -e
sites=$(grep -o 'fibio_event\.handler(' output_emitted.zig | wc -l | tr -d ' ')
if [ "$sites" -ne 3 ]; then
echo "FAIL: expected baseline 3 fibio_event.handler( sites, found $sites — effect-bearing recursion was transformed"
exit 1
fi
if grep -qE 'n - 1\)?.*< 2|\(n - 1\) < 2' output_emitted.zig; then
echo "FAIL: parameter-substituted guard present — effect-bearing recursion was unrolled"
exit 1
fi