✓
Passing This code compiles and runs correctly.
Code
// PIN (collapse-before-unroll ordering, WAY-TWO leg): collapse-recursion
// runs before unroll-recursion in elaborate and admits this shape first —
// the emitted body must carry __koru_collapse_b1_fib and NO __koru_unroll_
// machine. expected.txt proves collapse preserves semantics.
import std/io
pub tor fib { n: i64 } -> i64
fib = if(n < 2)
| then -> n
| else |> fib(n: n - 1): a |> fib(n: n - 2): b -> a + b
fib(n: 10): r |> std/io:print.ln("{{ r:d }}")
Actual
55
Expected output
55
Flows
subflow ~fib click a branch to expand · @labels scroll to their anchor
if (n < 2)
flow ~fib click a branch to expand · @labels scroll to their anchor
fib (n: 10)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin (RE-PINNED for collapse-before-unroll ordering): collapse-recursion
# runs before unroll-recursion in elaborate, so this shape collapses to a
# closed form FIRST — the __koru_collapse_b1_fib marker must be present and
# the __koru_unroll_ machine must be absent. This pins ORDERING, not just
# collapse correctness (270_013-018 own that). expected.txt proves the
# collapse preserves semantics.
set -e
if ! grep -q '__koru_collapse_b1_fib' output_emitted.zig; then
echo "FAIL: __koru_collapse_b1_fib marker absent — collapse did not fire before unroll"
exit 1
fi
if grep -q '__koru_unroll_' output_emitted.zig; then
echo "FAIL: __koru_unroll_ machine present — unroll fired on a collapse-admitted shape (ordering violated)"
exit 1
fi