✓
Passing This code compiles and runs correctly.
Code
// Template engine: `{% comp error %}` — a template makes a branch REQUIRED by
// referencing it. The consumer omits `| done`, so `continuations["done"]` is
// absent and the template raises a fantastic, author-defined diagnostic
// instead of letting a cryptic host-language error through. The template body
// IS the contract: by checking for `done`, the template declares it required.
~import std/io
~pub event probe2 { n: usize }
! each usize
~proc probe2|template|zig {
{% if continuations["done"] %}{% else %}{% comp error %}probe2 requires a `done` branch{% endcomp %}{% endif %}
for (0..{{ n }}) |__i| {
{% for h in effects["each"] %}
{{ h.link }}(__i);
{% endfor %}
}
}
~probe2(n: 3)
! each i |> std/io:print.ln("each {{ i:d }}")
Must fail at runtime:
Program must error when executed.
Error Verification
Actual Compiler Output
error[KORU120]: probe2 requires a `done` branch
--> tests/regression/200_COMPILER_FEATURES/250_TEMPLATE_ENGINE/250_005_missing_branch_comp_error/input.kz:21:0Test Configuration
MUST_FAIL