✓
Passing This code compiles and runs correctly.
Code
// Template engine: `{% if %}` COMPARES — `==` / `!=` between an operand and a
// "quoted literal", not only bare-key truthiness. Four cells, one per row of
// the grammar: `==` fires on a match, stays quiet on a non-match; `!=` sees a
// bound key as non-empty, and a MISSING key as the empty string — the same
// reading the bare-key path gives a missing key when it calls it false.
//
// `key != ""` is the only honest test for "bound and non-empty", and it is what
// a dispatch template needs to tell a guarded arm from its catch-all. What it
// costs when the engine cannot parse it is pinned end-to-end by 320_138.
~import std/io
~pub tor probe-cmp { n: usize }
~[template]proc probe-cmp|zig {
{% if n == "3" %}@import("std").debug.print("eq-match\n", .{});{% endif %}
{% if n == "4" %}@import("std").debug.print("eq-nonmatch\n", .{});{% endif %}
{% if n != "" %}@import("std").debug.print("ne-bound\n", .{});{% endif %}
{% if missing != "" %}@import("std").debug.print("ne-missing-bound\n", .{});{% else %}@import("std").debug.print("ne-missing-empty\n", .{});{% endif %}
}
// JS sibling — all four comparison cells, pinned on the JS target. Which cells
// fire is decided entirely by the engine (bound vs missing key, `==` vs `!=`),
// so the two variants MUST select the same four; the host text is only what the
// selected cells print. `console.log` supplies the trailing newline.
~[template]proc probe-cmp|js {
{% if n == "3" %}console.log("eq-match");{% endif %}
{% if n == "4" %}console.log("eq-nonmatch");{% endif %}
{% if n != "" %}console.log("ne-bound");{% endif %}
{% if missing != "" %}console.log("ne-missing-bound");{% else %}console.log("ne-missing-empty");{% endif %}
}
~probe-cmp(n: 3)
Actual
eq-match
ne-bound
ne-missing-empty
Expected output
eq-match
ne-bound
ne-missing-empty
Flows
flow ~probe-cmp click a branch to expand · @labels scroll to their anchor
probe-cmp (n: 3)
Test Configuration
MUST_RUN