✓
Passing This code compiles and runs correctly.
Code
// Test: per-call template with captured-argument substitution.
// `count-to(n: 3)` captures `3` as the Expression text for `n`. The
// template interpolates `{{ n }}` into the Zig body. Each call site
// substitutes ITS captured value, so this is the foundation of macro-
// shaped events like `for`, `if`, etc.
const std = @import("std");
~pub tor count-to { n: i32 }
~[template]proc count-to|zig {
var i: i32 = 0;
while (i < {{ n }}) : (i += 1) {
std.debug.print("{d}\n", .{i});
}
}
// JS sibling — same pin: the call site's captured `n` is interpolated into the
// loop bound, which is what makes macro-shaped events possible. The Zig half
// spells the loop `while (i < n) : (i += 1)`; the JS half is a counting `for`,
// the form that hands the engine a known trip count.
~[template]proc count-to|js {
for (let i = 0; i < {{ n }}; i++) {
console.log(i);
}
}
~count-to(n: 3)
Actual
0
1
2
Expected output
0
1
2
Flows
flow ~count-to click a branch to expand · @labels scroll to their anchor
count-to (n: 3)
Test Configuration
MUST_RUN