✓
Passing This code compiles and runs correctly.
Code
// PIN (collapse-recursion pass, WAY-TWO leg): pow-mod's multiplicative
// accumulator (acc*base mod P, e decreasing) admits R2b square-and-multiply —
// O(log e) instead of O(e). The kebab-case event name must mangle to
// pow_mod_event in the residual spelling (writeMangledSeg parity) — an
// unmangled `pow-mod_event` parses as subtraction and fails the backend.
// 3^10 mod 1e9+7 = 59049 proves semantics.
import std/io
pub tor pow-mod { base: i64, e: i64, acc: i64 } -> i64
pow-mod = if(e == 0)
| then -> acc
| else |> pow-mod(base, e: e - 1, acc: @rem(acc * base, 1000000007)): v -> v
pow-mod(base: 3, e: 10, acc: 1): r |> std/io:print.ln("{{ r:d }}")
Actual
59049
Expected output
59049
Flows
subflow ~pow-mod click a branch to expand · @labels scroll to their anchor
if (e == 0)
flow ~pow-mod click a branch to expand · @labels scroll to their anchor
pow-mod (base: 3, e: 10, acc: 1)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: collapse-recursion fires R2b on pow-mod. Marker + square-and-multiply
# fingerprint + SNAKE-CASE residual (pow_mod_event, not pow-mod_event) —
# the kebab mangle is the load-bearing detail this pin guards.
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 pow-mod"
exit 1
fi
if grep -q 'pow-mod_event' output_emitted.zig; then
echo "FAIL: unmangled kebab residual pow-mod_event present — parses as subtraction"
exit 1
fi
if ! grep -q 'pow_mod_event.handler' output_emitted.zig; then
echo "FAIL: snake residual pow_mod_event.handler absent"
exit 1
fi