022 args cross target

✓ Passing This code compiles and runs correctly.

Code

input.kz

Actual

hello
world

Expected output

✓ Zig✗ JavaScript
hello
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