✓
Passing This code compiles and runs correctly.
Code
// PIN (collapse-recursion pass, WAY-TWO leg): fib's two-call produce shape
// admits B1 fast-doubling for n <= 91 — O(log n) instead of the exponential
// tree. Marker __koru_collapse_b1_fib, @clz-based bit scan, i64 doubling
// recurrence. n=10 -> 55 proves 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: collapse-recursion fires B1 fast-doubling on fib. Marker + @clz bit-scan
# fingerprint prove the O(log n) body emitted, not the tree recursion.
set -e
if ! grep -q '__koru_collapse_b1_fib' output_emitted.zig; then
echo "FAIL: __koru_collapse_b1_fib marker absent — collapse pass did not fire on fib"
exit 1
fi
if ! grep -q '@clz' output_emitted.zig; then
echo "FAIL: fast-doubling bit scan (@clz) absent — B1 body not emitted"
exit 1
fi