111 effect branch multikind cross target

✓ Passing This code compiles and runs correctly.

Code

input.k

Actual

tokens=5 warnings=3 sum=10

Expected output

✓ Zig✓ JavaScript
tokens=5 warnings=3 sum=10
Emitted JavaScript source
let tokens = 0;
let warnings = 0;
let token_sum = 0;
const main_module = {
  tokenize_event: {
    handler(input, H) {
      const token = H.token;
      const warning = H.warning;
      const n = input.n;
      for (let i = 0; i < n; i++) {
      token(i);
      if (i % 2 == 0) {
      warning(i);
      }
      }
    },
  },
  onToken_event: {
    handler(input) {
      const t = input.t;
      tokens = tokens + 1; token_sum = token_sum + t;
    },
  },
  onWarning_event: {
    handler(input) {
      const w = input.w;
      warnings = warnings + 1;
    },
  },
  report_event: {
    handler(input) {
      console.log("tokens=" + tokens + " warnings=" + warnings + " sum=" + token_sum);
    },
  },
  flow0() {
    const __arg_0 = 5;
    {
      const n = __arg_0;
      for (let i = 0; i < n; i++) {
      {
        const t = i;
        {
          tokens = tokens + 1; token_sum = token_sum + t;
        }
      }
      if (i % 2 == 0) {
      {
        const w = i;
        {
          warnings = warnings + 1;
        }
      }
      }
      }    }
  },
  flow1() {
    {
      console.log("tokens=" + tokens + " warnings=" + warnings + " sum=" + token_sum);
    }
  },
};
main_module.flow0();
main_module.flow1();

Test Configuration

MUST_RUN