✓
Passing This code compiles and runs correctly.
Code
// Pins profiler x [parallel]for: under --profile the tap wrap around each
// branch handler must preserve the handler's `!` effect kind, so the
// parallel lowering's partition + additive combine survives instrumentation.
// The checksum is the serial fold's answer; the trace carries the loop's
// transitions on a closed JSON stream.
import std/io
[profile]import std/profiler
capture { acc: 0[i64] }
! as a |> [parallel]for(1..1001)
! each i |> captured { acc: a.acc + @as(i64, @intCast(i)) }
| captured r |> std/io:print.ln("{{ r.acc:d }}")
Actual
500500
Expected output
500500
Flows
flow ~capture click a branch to expand · @labels scroll to their anchor
capture (source: acc: 0[i64])
Test Configuration
MUST_RUN
Compiler Flags:
--profilePost-validation Script:
#!/bin/bash
# Validates Chrome trace: the parallel fold's loop and fold-cell transitions
# are captured end to end and the profiler stays invisible to itself.
if [ -f "koru_profile.snapshot.json" ]; then
PROFILE_FILE="koru_profile.snapshot.json"
else
PROFILE_FILE="/tmp/koru_profile.json"
fi
if [ ! -f "$PROFILE_FILE" ]; then
echo "ERROR: no trace at $PROFILE_FILE"
exit 1
fi
if ! grep -q '"traceEvents"' "$PROFILE_FILE"; then
echo "ERROR: missing traceEvents"
cat "$PROFILE_FILE"
exit 1
fi
if ! grep -q '"std.control:for"' "$PROFILE_FILE"; then
echo "ERROR: std.control:for transition missing"
cat "$PROFILE_FILE"
exit 1
fi
if ! grep -q '"input:captured"' "$PROFILE_FILE"; then
echo "ERROR: input:captured transition missing"
cat "$PROFILE_FILE"
exit 1
fi
if ! grep -q '"std.io:print.ln"' "$PROFILE_FILE"; then
echo "ERROR: std.io:print.ln transition missing"
cat "$PROFILE_FILE"
exit 1
fi
if ! grep -q '^]}$' "$PROFILE_FILE"; then
echo "ERROR: JSON not closed"
cat "$PROFILE_FILE"
exit 1
fi
if grep -qE 'write-event|write-header|write-footer' "$PROFILE_FILE"; then
echo "ERROR: profiler observed itself"
cat "$PROFILE_FILE"
exit 1
fi
echo "trace valid"
exit 0