✓
Passing Passing: the compiler rejects this program as expected.
Code
// A step chain inside a fold arm refuses — v1 arms are single `-> expr`
// terminals; spell the work as a tor and call it.
import std/tree
std/tree:node(Node) { item: i64, left: ?Node }
pub tor double { x: i64 } -> i64
double = if(true)
| then -> x * 2
| else -> 0
pub tor mk { } -> *Node<owned!>
mk = if(true)
| then |> std/tree:mint(Node) { item: 1, left: null }: h -> h
| else -> null
mk(): t
|> std/tree:fold(t, as: i64): c
| node n |> double(x: n.item): d -> d + n.left
| null -> 0
|> std/tree:dispose(t): _
Actual compiler output
error[KORU184]: std/tree:fold(t): the 'node' arm must be a single produce — `| node <bind> -> <expr>`; step chains inside a fold arm are a v1 cut (spell the work as a tor and call it)
--> tests/regression/600_STDLIB/682_TREE/682_018_fold_step_chain_arm/input.k:18:1Must contain:
KORU184Flows
flow ~node click a branch to expand · @labels scroll to their anchor
node (Node, source: item: i64, left: ?Node)
subflow ~double click a branch to expand · @labels scroll to their anchor
if (true)
subflow ~mk click a branch to expand · @labels scroll to their anchor
if (true)
flow ~mk click a branch to expand · @labels scroll to their anchor
mk
Test Configuration
MUST_ERROR