✓
Passing Passing: the compiler rejects this program as expected.
Code
// An OPTIONAL terminal branch armed with a bare `_` discard is illegal.
// `for` declares `| ?done` — omitting the arm already discards it, so an
// explicit `| done |> _` is pure noise that misreads as "required, consciously
// ignored" and would silently swallow the event if the branch were later
// promoted to REQUIRED. Omit it, or give it a real body.
import std/io
import std/control
for(0..3)
! each i |> std/io:print.ln("{{ i:d }}")
| done |> _
Actual compiler output
error[KORU054]: no-op `_` body on optional terminal branch 'done' — arming an optional outcome only to discard it is pure noise
--> tests/regression/400_RUNTIME_FEATURES/400_197_optional_terminal_noop_arm_illegal/input.k:11:0
|
11 | | done |> _
| ^
hint: omit the arm entirely — an unarmed optional branch already discards the outcome. A no-op is also a hazard: if 'done' is later promoted to REQUIRED, this arm would silently swallow it instead of surfacing the must-handle error. To act, replace `_` with a real step; to intentionally handle-and-ignore, the branch must be REQUIRED (drop the `?`), not optional.Frontend must reject with:
CONTAINS KORU054Flows
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..3)
Test Configuration
MUST_ERROR LANGUAGES: zig cs