✓
Passing This code compiles and runs correctly.
Code
// PIN (collapse-recursion pass, WAY-TWO leg): loop-k's accumulator
// (@rem(acc + i*j*k, P), k decreasing, i/j threaded) admits R2a — the
// additive Faulhaber sum under modulus in i128 with exact checked fallback.
// Multi-param coeff (i*j) exercises the coeff-guard spine. Kebab name
// loop-k must residual-spell loop_k_event. Sum_{j=1..4} 2*3*j = 60.
import std/io
pub tor loop-k { i: i64, j: i64, k: i64, acc: i64 } -> i64
loop-k = if(k == 0)
| then -> acc
| else |> loop-k(i, j, k: k - 1, acc: @rem(acc + i * j * k, 1000000007)): v -> v
loop-k(i: 2, j: 3, k: 4, acc: 0): r |> std/io:print.ln("{{ r:d }}")
Actual
60
Expected output
60
Flows
subflow ~loop-k click a branch to expand · @labels scroll to their anchor
if (k == 0)
flow ~loop-k click a branch to expand · @labels scroll to their anchor
loop-k (i: 2, j: 3, k: 4, acc: 0)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: collapse-recursion fires R2a on loop-k — additive Faulhaber under
# modulus. Marker + i128 widen fingerprint + snake residual loop_k_event.
set -e
if ! grep -q '__koru_collapse_r2' output_emitted.zig; then
echo "FAIL: __koru_collapse_r2 marker absent — collapse pass did not fire on loop-k"
exit 1
fi
if grep -q 'loop-k_event' output_emitted.zig; then
echo "FAIL: unmangled kebab residual loop-k_event present — parses as subtraction"
exit 1
fi
if ! grep -q 'i128' output_emitted.zig; then
echo "FAIL: i128 widen absent — additive mod-form not emitted"
exit 1
fi