✗
Failing This test is currently failing.
Failed: backend-exec
Error Details
transform pass failed (TransformPreambleAtNestedSite). The pipeline cannot continue with a partially-transformed AST. Panic: transform pass failed — see error above
Failure Output
Showing last 10 of 66 lines
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/320_STDLIB/320_098_capture_nested_site/backend.zig:190:51: 0x1009c79ef in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^
/opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:627:37: 0x1009cd6ab in main (backend)
const result = root.main() catch |err| {
^
???:?:?: 0x18da2fdff in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 256: 78861 Abort trap: 6 ./backend output Code
// RED PIN — capture nested under a continuation crashes the transform pass.
// `capture` was built for FLOW LEVEL only; nesting it under a continuation
// (here `| count _`) is a MULTI-LAYER gap, not a one-line fix (probed 2026-06-15):
// layer 1: itemToNode rejects flow-level preamble_code at a nested site
// (TransformPreambleAtNestedSite). Migrating preamble→front-of-
// inline_body clears it — but then:
// layer 2: the shape checker rejects the spliced capture continuations as a
// duplicate branch handler (SHAPE002), and likely more below (emission).
// So this needs a real rework of capture (or the nested-site splice) across
// transform_pass_runner + shape_checker + emission — a dedicated investigation,
// not a patch. Blocks the canonical "build a collection, THEN fold it with an
// accumulator" shape (e.g. AoC day17's subset count).
// Minimal — no list / read-lines, just capture under a scalar branch.
import std/io
import std/args
std/args:count()
| count _ |> capture { n: 0[i64] }
! as acc |> captured { n: acc.n + 1 }
| captured r |> std/io:print.ln("n={{ r.n:d }}")
Expected output
n=1
Test Configuration
MUST_RUN