✓
Passing Passing: the compiler rejects this program as expected.
Code
// A fold over a node whose edge reaches a DIFFERENT node kind refuses —
// v1 folds are single-kind; heterogeneous folds need per-kind arms.
import std/tree
std/tree:node(Leaf) { v: i64 }
std/tree:node(Node) { item: i64, kid: ?Leaf }
pub tor mk { } -> *Node<owned!>
mk = if(true)
| then |> std/tree:mint(Node) { item: 1, kid: null }: h -> h
| else -> null
mk(): t
|> std/tree:fold(t, as: i64): c
| node n -> n.item + 1
| null -> 0
|> std/tree:dispose(t): _
Actual compiler output
error[KORU184]: std/tree:fold(t): edge 'kid: Leaf' reaches a different node kind — v1 folds are single-kind (heterogeneous folds need per-kind arms, which the surface hasn't decided)
--> tests/regression/600_STDLIB/682_TREE/682_014_fold_heterogeneous_edge/input.k:14:1Must contain:
KORU184Flows
flow ~node click a branch to expand · @labels scroll to their anchor
node (Leaf, source: v: i64)
flow ~node click a branch to expand · @labels scroll to their anchor
node (Node, source: item: i64, kid: ?Leaf)
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