✓
Passing This code compiles and runs correctly.
Code
// Test: per-call template where the captured argument is a range
// expression. `0..3` is captured as the Expression text for `r`. The
// template interpolates it directly into a Zig `for` loop. This is the
// canonical `for` migration shape — the receipt that per-call templates
// can replace the [keyword|comptime|transform] for machinery.
const std = @import("std");
~pub tor each-in { r: i32 }
~[template]proc each-in|zig {
for ({{ r }}) |item| std.debug.print("{d}\n", .{item});
}
// JS sibling, and the interesting one: the captured Expression text is `0..3`,
// a ZIG range. It is not a JS iterable, so this is where a per-call template
// stops being a substitution and becomes a real per-target lowering. The
// `parse_range` filter (template_processor.zig) classifies the captured text;
// a range lowers to a counting loop, anything else flows through as `for…of`.
// Identical treatment to koru_std's own `for|template|js` — one filter, one
// classification, both consumers.
~[template]proc each-in|js {
{% const __r = parse_range(r) %}{% if __r.is_range %}for (let item = {{ __r.lo }}; item < {{ __r.hi }}; item++) console.log(item);{% else %}for (const item of {{ r }}) console.log(item);{% endif %}
}
~each-in(r: 0..3)
Actual
0
1
2
Expected output
0
1
2
Flows
flow ~each-in click a branch to expand · @labels scroll to their anchor
each-in (r: 0..3)
Test Configuration
MUST_RUN