The generated code is safe, but the `reset/reuse` optimization will never be applicable at runtime. The issue is that `insert_reset_reuse_fn` is not checking the joint points. I will fix the bug only at `resetreuse.lean`.
12 lines
415 B
Text
12 lines
415 B
Text
@[noinline] def g (x : Nat × Nat) := x
|
||
|
||
set_option trace.compiler.boxed true
|
||
|
||
@[noinline] def f (b : Bool) (x : Nat × Nat) : (Nat × Nat) × (Nat × Nat) :=
|
||
let done (y : Nat × Nat) := (g (g (g y)), x) in
|
||
match b with
|
||
| true := match x with | (a, b) := done (a, 0)
|
||
| false := match x with | (a, b) := done (0, b)
|
||
|
||
def main (xs : List String) : IO Unit :=
|
||
IO.println $ f true (xs.head.toNat, xs.tail.head.toNat)
|