✓
Passing This code compiles and runs correctly.
Code
// Cross-target `~for(0..3)` with a `print` effect-handler body. Pins the whole
// chain lowering identically to Zig and JS:
// - `for|template|js` (koru_std/control.kz) is selected on a --lang=js build;
// - the range iterable `0..N` lowers to a JS counting loop
// (`for (let i = 0; i < N; i++)`) via `parse_range` (template_processor.zig),
// not a verbatim `for (… of 0..N)` that node would reject;
// - the `! each` effect splice binds the item and runs the handler body; and
// - that handler body — `std/io:print(...)`, a comptime|transform nested as an
// effect-splice body — lowers through its `|js` variant, spliced by the JS
// emitter from the invocation's `inline_body`, not emitted as a `.impl` call.
// A JS-array iterable (`~for([1,2,3])`) rides the same path as a `for…of`.
~import std/control
~import std/io
~for(0..3)
! each _ |> std/io:print("tick\n")
| done |> _
Actual
tick
tick
tick
Expected output
✓ Zig✓ JavaScripttick
tick
tick
Emitted JavaScript source
const main_module = {
flow0() {
for (let __koru_item = 0; __koru_item < 3; __koru_item++) {
{ const _auto_6 = __koru_item; process.stdout.write("tick\n");
}
}
{ }
},
};
main_module.flow0();
Flows
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..3)
Test Configuration
MUST_RUN