mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-04 01:03:36 +03:00
2.0 KiB
2.0 KiB
Tests cases that produced bad decompilation output previously. There are three cases that need to be 'fixed up.'
- lambda expressions with free variables need to be beta reduced
- let defined functions need to have arguments removed and occurrences rewritten.
- let-rec defined functions need to have arguments removed, but it is a more complicated process.
> Any (w x -> let
f0 y = match y with
0 -> x
n -> 1 + f1 (drop y 1)
f1 y = match y with
0 -> w + x
n -> 1 + f0 (drop y 1)
f2 x = f2 x
f3 y = 1 + y + f2 x
g h = h 1 + x
g (z -> x + f0 z))
Loading changes detected in scratch.u.
✅
scratch.u changed.
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
1 | > Any (w x -> let
⧩
Any
(w x ->
let
use Nat + drop
f1 y = match y with
0 -> w + x
n -> 1 + f0 (drop y 1)
f0 y = match y with
0 -> x
n -> 1 + f1 (drop y 1)
f2 x = f2 x
f3 x y = 1 + y + f2 x
g h = h 1 + x
g (z -> x + f0 z))
Also check for some possible corner cases.
f
should not have its x
argument eliminated, because it doesn't
always occur with x
as the first argument, but if we aren't careful,
we might do that, because we find the first occurrence of f
, and
discard its arguments, where f
also occurs.
> Any (x -> let
f x y = match y with
0 -> 0
_ -> f x (f y (drop y 1))
f x 20)
Loading changes detected in scratch.u.
✅
scratch.u changed.
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
1 | > Any (x -> let
⧩
Any
(x ->
let
f x y = match y with
0 -> 0
_ -> f x (f y (Nat.drop y 1))
f x 20)