✓
Passing Passing: the compiler rejects this program as expected.
Code
// A fold with no `| null` arm refuses: every `?` edge and every `?*Node`
// root reaches the empty case — the base is a law, not a default.
import std/tree
std/tree:node(Node) { item: i64, left: ?Node }
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 -> n.item + n.left
|> std/tree:dispose(t): _
Actual compiler output
error[KORU184]: std/tree:fold(t): missing `| null -> <expr>` — every `?` edge and every `?*Node` root reaches the empty case; spell it
--> tests/regression/600_STDLIB/682_TREE/682_013_fold_missing_null_arm/input.k:13:1Must contain:
KORU184Flows
flow ~node click a branch to expand · @labels scroll to their anchor
node (Node, source: item: i64, left: ?Node)
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