mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
44 lines
809 B
Markdown
44 lines
809 B
Markdown
Tests a variable capture problem.
|
|
|
|
After pattern compilation, the match would end up:
|
|
|
|
```
|
|
T p1 p3 p3
|
|
```
|
|
|
|
and z would end up referring to the first p3 rather than the second.
|
|
|
|
``` unison
|
|
structural type Trip = T Nat Nat Nat
|
|
|
|
bad : Nat -> (Nat, Nat)
|
|
bad x = match Some (Some x) with
|
|
Some (Some x) -> match T 3 4 5 with
|
|
T _ _ z -> (x, z)
|
|
_ -> (0,0)
|
|
|
|
> bad 2
|
|
```
|
|
|
|
``` ucm
|
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
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`:
|
|
|
|
structural type Trip
|
|
bad : Nat -> (Nat, Nat)
|
|
|
|
Now evaluating any watch expressions (lines starting with
|
|
`>`)... Ctrl+C cancels.
|
|
|
|
9 | > bad 2
|
|
⧩
|
|
(2, 5)
|
|
|
|
```
|