✓
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
// a `std/store:stored` write inside the recursive branch — a store/memory
// effect. Unrolling would duplicate the write across substituted body
// copies, so the pass must decline: baseline 3 `fibs_event.handler(` sites,
// no substituted guards, correct output.
import std/io
import std/store
std/store:new(game) { score: 0[i64] }
pub tor fibs { n: i64 } -> i64
fibs = if(n < 2)
| then -> n
| else |> fibs(n: n - 1): a
|> std/store:stored { game.score: game.score + 1 }
|> fibs(n: n - 2): b -> a + b
fibs(n: 5): r |> std/io:print.ln("{{ r:d }}")
Actual
5
Expected output
5
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (game, source: score: 0[i64])
subflow ~fibs click a branch to expand · @labels scroll to their anchor
if (n < 2)
flow ~fibs click a branch to expand · @labels scroll to their anchor
fibs (n: 5)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: recursion bearing a store write (std/store:stored inside the
# recursive branch) must NOT be unrolled — the emitted shape stays at the
# baseline 3 `fibs_event.handler(` sites with no parameter-substituted
# guards. Refusal is silent: the program still runs and prints correctly.
set -e
sites=$(grep -o 'fibs_event\.handler(' output_emitted.zig | wc -l | tr -d ' ')
if [ "$sites" -ne 3 ]; then
echo "FAIL: expected baseline 3 fibs_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