✓
Passing This code compiles and runs correctly.
Code
// NOTE: narrowed to Zig — print.ln of a bare variable WITH newline has no JS
// variant yet (print.ln is a Zig comptime transform; std/io:print has |js but no
// newline). print.ln cross-target JS for variable args is a tracked gap.
// Dual-target: the SAME .kz reads argv via std/args on both Zig and JS.
// ARGS = "hello\nworld" → Koru argv index 1 = hello, 2 = world (both targets).
~import std/args
~import std/io
~std/args:get(index: 1)
| arg a |> std/io:print.ln(a)
| out-of-bounds |> std/io:print("<none>\n")
~std/args:get(index: 2)
| arg a |> std/io:print.ln(a)
| out-of-bounds |> std/io:print("<none>\n")
Actual
hello
world
Expected output
✓ Zig✗ JavaScripthello
world
Emitted JavaScript source
const main_module = {
get_event: {
handler(input) {
const index = input.index;
if (index + 1 >= process.argv.length) {
return { tag: "out_of_bounds" };
}
return { tag: "arg", arg: process.argv[index + 1] };
},
},
println_event: {
handler(input) {
const text = input.text;
console.log(text);
},
},
flow0() {
const result_0 = main_module.get_event.handler({ index: 1 });
if (result_0.tag === "arg") {
const a = result_0.arg;
main_module.println_event.handler({ text: a });
}
if (result_0.tag === "out_of_bounds") {
main_module.println_event.handler({ text: "<none>" });
}
},
flow1() {
const result_1 = main_module.get_event.handler({ index: 2 });
if (result_1.tag === "arg") {
const a = result_1.arg;
main_module.println_event.handler({ text: a });
}
if (result_1.tag === "out_of_bounds") {
main_module.println_event.handler({ text: "<none>" });
}
},
};
main_module.flow0();
main_module.flow1();
Test Configuration
MUST_RUN