✓
Passing Passing: the compiler rejects this program as expected.
Code
// PIN — a `| name` branch arm written MID-LINE is refused, not silently
// dropped.
//
// THE SHAPE: `| then |> if (k) | then |> step` — the second `| then`
// continues the line inside the outer then-arm's body. Branch arms open on
// their own line; mid-line the arm has no legal construct to dispatch on.
//
// WHAT IT DID BEFORE: parseEventInvocation truncated the invocation head at
// the first top-level `|` and dropped the arm silently — the inner `if`
// emitted `if (k) {} else {}` (a required-`then` with an EMPTY true arm) and
// the step ran unconditionally. oshun's field_cam.k hit this: every kind
// label drew on every card.
//
// LEGAL NEIGHBOURS kept open: `| name` after `->`/`=>` belongs to the
// produce tail (event taps, 420_008), and `| name` directly after `}` arms
// the closed block invocation (`fmt.blk { … } | formatted`, 390_004).
import std/io
pub tor start {} -> { }
start = std/io:print.ln("start")
|> if (true)
| then |> if (false) | then |> std/io:print.ln("WRONG")
|> std/io:print.ln("done")
Actual compiler output
error[PARSE001]: branch arm '| then' written mid-line — branch arms open on their own line
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_332_midline_branch_arm_refused/input.k:23:12
|
23 | | then |> if (false) | then |> std/io:print.ln("WRONG")
| ^
hint: a `| name` arm dispatches on the step it follows; put it on a new line indented under that step. A same-line next step chains with `|>`.Frontend must reject with:
CONTAINS error[PARSE001]
CONTAINS branch arm '| then' written mid-line
ERROR_AT 23Test Configuration
MUST_ERROR