✗
Failing This test is currently failing.
Failed: js-runtime
Failure Output
🎯 Compiler coordination: Passes: 14 (flow-based: frontend, analysis, emission) Code
// FRONTIER: ~for now HONESTLY selects `for|template|js` on a --lang=js build
// (koru_std/control.kz), and the JS emitter resolves BOTH splice-marker kinds
// the template mints:
// - the per-iteration `! each` effect splice (`__koru_inline_scoped_0(item)`)
// lowers to `{ const _x = item; <handler body> }` — RESOLVED, no longer a
// leaked, unresolved marker; and
// - the `| done |> _` terminal's `__koru_continue_N` lowers to an empty block,
// as `_` should.
// Proven with a JS-array iterable: `~for([1,2,3]) ! each _ |> println(...)`
// emits a runnable `for (const x of [1,2,3]) { … }` that prints tick×3.
//
// The ONE remaining gap is the iterable EXPRESSION: `{{ iterable }}` substitutes
// `0..3` verbatim, so the JS body becomes `for (const x of 0..3)` — `0..3` is
// Zig range syntax, not a JS iterable, and node rejects it. Closing this needs
// range→JS lowering (`0..N` → a counting loop or `Array.from`/generator), a
// target-aware transform of the iterable expression that does not exist yet.
// That is the whole of what's left; the for-body + effect-splice lowering is done.
~import std/control
~import std/io
~for(0..3)
! each _ |> std/io:print("tick\n")
| done |> _
Actual · Zig
✓ passtick
tick
tick
Actual · JavaScript
✗ js-runtime/Users/larsde/src/koru/tests/regression/100_MODULE_SYSTEM/140_FILE_LAYOUT/140_014_for_template_cross_target/output_emitted.js:4
{ const _auto_6 = __koru_item; main_module.impl_event.handler({ expr: "tick\n" });
^
TypeError: Cannot read properties of undefined (reading 'handler')
at Object.flow0 (/Users/larsde/src/koru/tests/regression/100_MODULE_SYSTEM/140_FILE_LAYOUT/140_014_for_template_cross_target/output_emitted.js:4:69)
at Object.<anonymous> (/Users/larsde/src/koru/tests/regression/100_MODULE_SYSTEM/140_FILE_LAYOUT/140_014_for_template_cross_target/output_emitted.js:11:13)
at Module._compile (node:internal/modules/cjs/loader:1829:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1969:10)
at Module.load (node:internal/modules/cjs/loader:1552:32)
at Module._load (node:internal/modules/cjs/loader:1354:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47
Node.js v25.9.0
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; main_module.impl_event.handler({ expr: "tick\n" });
}
}
{ }
},
};
main_module.flow0();
Test Configuration
MUST_RUN