2022-03-31 00:21:32 +03:00
|
|
|
This tests a variable related bug in the ANF compiler.
|
|
|
|
|
|
|
|
The nested let would get flattened out, resulting in:
|
|
|
|
|
2024-07-15 21:10:27 +03:00
|
|
|
```
|
|
|
|
bar = result
|
|
|
|
```
|
2022-03-31 00:21:32 +03:00
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
which would be handled by renaming. However, the *context* portion of
|
2022-03-31 00:21:32 +03:00
|
|
|
the rest of the code was not being renamed correctly, so `bar` would
|
|
|
|
remain in the definition of `baz`.
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2022-03-31 00:21:32 +03:00
|
|
|
foo _ =
|
|
|
|
id x = x
|
2022-12-02 08:51:11 +03:00
|
|
|
void x = ()
|
2022-03-31 00:21:32 +03:00
|
|
|
bar = let
|
2022-12-02 08:51:11 +03:00
|
|
|
void (Debug.watch "hello" "hello")
|
2022-03-31 00:21:32 +03:00
|
|
|
result = 5
|
2022-12-02 08:51:11 +03:00
|
|
|
void (Debug.watch "goodbye" "goodbye")
|
2022-03-31 00:21:32 +03:00
|
|
|
result
|
|
|
|
baz = id bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
> !foo
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2022-03-31 00:21:32 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2022-03-31 00:21:32 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
|
|
|
foo : ∀ _. _ -> Nat
|
|
|
|
|
|
|
|
Now evaluating any watch expressions (lines starting with
|
|
|
|
`>`)... Ctrl+C cancels.
|
|
|
|
|
2022-12-02 08:51:11 +03:00
|
|
|
12 | > !foo
|
2022-03-31 00:21:32 +03:00
|
|
|
⧩
|
|
|
|
5
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> add
|
2022-03-31 00:21:32 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
|
|
|
foo : ∀ _. _ -> Nat
|
|
|
|
|
|
|
|
```
|