✓
Passing This code compiles and runs correctly.
Code
// TEST: Parser bug — multi-line Source body at end of |> chain
//
// When the LAST kernel op in a |> chain has a multi-line Source body,
// the parser nests | computed c |> inside the kernel continuation
// instead of making it a sibling at the init level.
//
// Works:
// pairwise { multi-line } |> self { single-line } → computed is sibling
// pairwise { multi-line } (no chain) → computed is sibling
//
// Fails:
// pairwise { single } |> self { multi-line } → computed is nested
//
// Root cause: parser doesn't detect Source body end when body spans
// multiple lines AND is at the end of a |> chain.
~import "$std/kernel"
~import "$std/io"
~std.kernel:shape(Body) {
mass: f64,
}
~std.kernel:init(Body) {
{ mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },
}
| kernel k |>
std.kernel:pairwise { k.mass += k.other.mass * 0.1 }
|> std.kernel:self {
k.mass *= 2.0
}
| computed c |>
std.io:print.blk {
mass[0]={{ c[0].mass:f }} mass[1]={{ c[1].mass:f }} mass[2]={{ c[2].mass:f }}
}
Expected
mass[0]=3 mass[1]=4.6 mass[2]=6
Actual
mass[0]=3 mass[1]=4.6 mass[2]=6
Test Configuration
MUST_RUN