// Case-of-case (ADR 0043) moves a block's switch into the match on its // value and deletes the block's `let`: only when the match is the // value's only use. The uses an earlier rewrite gives the value count // too (issue #425): an alias's (`aliased`: `xs`'s block ends in a block // inlined into it) and an inlined function's parameter's (`inlined`: // `pick` uses `t` twice). Counting only the match left the other use // unbound, and `louise build` panicked. import std/io type T { A, B } // Recursive, so never inlined: its use of `t` stays a use. fn deep :: t: T n: Int -> Int { if n <= 0 { match t { A -> 10, B -> 20 } } else { deep t (n - 1) } } fn pick :: t: T -> Int { let r = match t { A -> 1, B -> 2 } r + deep t 3 } fn aliased :: n: Int -> () / { let xs = match Some(n) { None -> [61], Some(m) -> if m > 2 { [34] } else { [32] } } io.println (match xs { [] -> "empty", [x, ..rest] -> "first " <> show x }) io.println (show xs) } fn inlined :: n: Int -> () / { let t = if n > 26 { A } else { B } io.println (show (pick t)) } pub fn main :: -> () / { aliased 4 aliased 1 inlined 39 inlined 2 } //> first 34 //> [34] //> first 32 //> [32] //> 11 //> 22