unison/unison-src/transcripts/ability-term-conflicts-on-update.md

94 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

# Regression test for updates which conflict with an existing ability constructor
https://github.com/unisonweb/unison/issues/2786
```ucm:hide
2024-07-01 20:28:52 +03:00
scratch/main> builtins.merge lib.builtins
```
First we add an ability to the codebase.
Note that this will create the name `Channels.send` as an ability constructor.
```unison
unique ability Channels where
send : a -> {Channels} ()
```
```ucm
2024-07-01 20:28:52 +03:00
scratch/main> add
```
Now we update the ability, changing the name of the constructor, _but_, we simultaneously
add a new top-level term with the same name as the constructor which is being
removed from Channels.
```unison
unique ability Channels where
sends : [a] -> {Channels} ()
2022-01-17 19:59:32 +03:00
Channels.send : a -> ()
Channels.send a = ()
2023-07-21 09:12:22 +03:00
thing : '{Channels} ()
2022-01-17 19:59:32 +03:00
thing _ = send 1
```
These should fail with a term/ctor conflict since we exclude the ability from the update.
```ucm:error
2024-07-01 20:28:52 +03:00
scratch/main> update.old patch Channels.send
scratch/main> update.old patch thing
2022-01-17 19:59:32 +03:00
```
If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.
```unison
unique ability Channels where
sends : [a] -> {Channels} ()
Channels.send : a -> ()
Channels.send a = sends [a]
2023-07-21 09:12:22 +03:00
thing : '{Channels} ()
thing _ = send 1
```
2022-01-17 19:59:32 +03:00
These updates should succeed since `Channels` is a dependency.
```ucm
2024-07-01 20:28:52 +03:00
scratch/main> update.old.preview patch Channels.send
scratch/main> update.old.preview patch thing
2022-01-17 19:59:32 +03:00
```
We should also be able to successfully update the whole thing.
```ucm
2024-07-01 20:28:52 +03:00
scratch/main> update.old
```
2022-01-20 23:45:43 +03:00
# Constructor-term conflict
```ucm:hide
2024-07-01 20:28:52 +03:00
scratch/main2> builtins.merge lib.builtins
```
2022-01-20 23:45:43 +03:00
```unison
X.x = 1
```
```ucm
2024-07-01 20:28:52 +03:00
scratch/main2> add
2022-01-20 23:45:43 +03:00
```
2022-01-21 00:39:22 +03:00
```unison
2022-01-20 23:45:43 +03:00
structural ability X where
x : ()
```
This should fail with a ctor/term conflict.
```ucm:error
2024-07-01 20:28:52 +03:00
scratch/main2> add
2022-01-20 23:45:43 +03:00
```