✓
Passing Passing: the compiler rejects this program as expected.
Code
// Pins: a second `captured` write to a field already folded under
// [parallel] escapes the combine-law check — the partition replays ONE
// combine per field, so `acc + i` then `acc * 2` composes to something no
// single fold proves. Serial answer 1004; partitioned, the second write
// silently wins inside each worker and the join miscombines.
import std/io
capture { acc: 0[i64] }
! as a |> [parallel]for(1..9)
! each i |> captured { acc: a.acc + @as(i64, @intCast(i)) } |> captured { acc: a.acc * 2 }
| captured r |> std/io:print.ln("{{ r.acc:d }}")
Actual compiler output
error[KORU212]: [parallel]for: second write to `a.acc` under [parallel] — the join replays one combine per field; fold the writes into a single `captured { … }` expression or drop [parallel]
--> tests/regression/400_RUNTIME_FEATURES/400_231_parallel_for_second_cell_write_refused/input.k:11:5Error output must contain
second writeFlows
flow ~capture click a branch to expand · @labels scroll to their anchor
capture (source: acc: 0[i64])
Test Configuration
MUST_ERROR