Files
lean4/tests/playground/badreset.lean
Leonardo de Moura fd25827d3e fix(library/init/lean/compiler/ir/resetreuse): must use livevars instead of freevars
The file badreset contains two functions where the new `reset/reuse`
insertion procedure implemented in Lean produces better results than the
one implemented in C++.

cc @kha
2019-05-07 11:09:51 -07:00

24 lines
706 B
Lean4
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@[noinline] def g (x : Nat × Nat) := x
set_option trace.compiler.boxed true
set_option trace.compiler.lambda_pure true
@[noinline] def f (b : Bool) (x : Nat × Nat) : (Nat × Nat) × (Nat × Nat) :=
let done (y : Nat × Nat) := (g (g (g x)), y) in
match b with
| true := match x with | (a, b) := done (a, 0)
| false := match x with | (a, b) := done (0, b)
@[noinline] def h {α : Type} (x : Nat × α) := x.1
def tst2 (p : Nat × (Except Nat Nat)) : Nat × Nat :=
match p with
| (a, b) :=
let done (x : Nat) := (h p + 1, x) in
match b with
| Except.ok v := done v
| Except.error w := done w
def main (xs : List String) : IO Unit :=
IO.println $ f true (xs.head.toNat, xs.tail.head.toNat)