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

229 lines
4.9 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
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
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`:
ability Channels
```
``` ucm
2024-07-01 20:28:52 +03:00
scratch/main> add
⍟ I've added these definitions:
ability Channels
```
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
```
``` ucm
2022-01-17 19:59:32 +03:00
Loading changes detected in scratch.u.
2022-01-17 19:59: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`:
Channels.send : a -> ()
2023-07-21 09:12:22 +03:00
thing : '{Channels} ()
2022-01-17 19:59:32 +03:00
⍟ These names already exist. You can `update` them to your
new definition:
ability Channels
2022-01-17 19:59:32 +03:00
```
These should fail with a term/ctor conflict since we exclude the ability from the update.
``` ucm
2024-07-01 20:28:52 +03:00
scratch/main> update.old patch Channels.send
2022-01-17 19:59:32 +03:00
x These definitions failed:
Reason
term/ctor collision Channels.send : a -> ()
Tip: Use `help filestatus` to learn more.
2024-07-01 20:28:52 +03:00
scratch/main> update.old patch thing
2022-01-17 19:59:32 +03:00
2023-07-21 09:12:22 +03:00
⍟ I've added these definitions:
2022-01-17 19:59:32 +03:00
2023-07-21 09:12:22 +03:00
Channels.send : a -> ()
thing : '{Channels} ()
2022-01-17 19:59:32 +03:00
2023-07-21 09:12:22 +03:00
⍟ I've updated these names to your new definition:
ability Channels
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.
2022-01-17 19:59:32 +03:00
``` unison
2022-01-17 19:59:32 +03:00
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
```
``` 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:
2023-07-21 09:12:22 +03:00
⊡ Previously added definitions will be ignored: Channels
⍟ These names already exist. You can `update` them to your
new definition:
2023-07-21 09:12:22 +03:00
Channels.send : a ->{Channels} ()
thing : '{Channels} ()
```
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
2022-01-17 19:59: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:
2023-07-21 09:12:22 +03:00
⊡ Previously added definitions will be ignored: Channels
2022-01-17 19:59:32 +03:00
⍟ These names already exist. You can `update` them to your
new definition:
2023-07-21 09:12:22 +03:00
Channels.send : a ->{Channels} ()
2022-01-17 19:59:32 +03:00
2024-07-01 20:28:52 +03:00
scratch/main> update.old.preview patch thing
2022-01-17 19:59: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:
2023-07-21 09:12:22 +03:00
⊡ Previously added definitions will be ignored: Channels
2022-01-17 19:59:32 +03:00
⍟ These names already exist. You can `update` them to your
new definition:
2023-07-21 09:12:22 +03:00
Channels.send : a ->{Channels} ()
thing : '{Channels} ()
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
2023-07-21 09:12:22 +03:00
⊡ Ignored previously added definitions: Channels
⍟ I've updated these names to your new definition:
2023-07-21 09:12:22 +03:00
Channels.send : a ->{Channels} ()
thing : '{Channels} ()
```
2022-01-21 00:39:22 +03:00
# Constructor-term conflict
``` unison
2022-01-21 00:39:22 +03:00
X.x = 1
```
``` ucm
2022-01-21 00:39:22 +03:00
Loading changes detected in scratch.u.
2022-01-21 00:39:22 +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`:
X.x : Nat
```
``` ucm
2024-07-01 20:28:52 +03:00
scratch/main2> add
2022-01-21 00:39:22 +03:00
⍟ I've added these definitions:
X.x : Nat
```
``` unison
2022-01-21 00:39:22 +03:00
structural ability X where
x : ()
```
``` ucm
2022-01-21 00:39:22 +03:00
Loading changes detected in scratch.u.
2022-01-21 00:39:22 +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:
x These definitions would fail on `add` or `update`:
Reason
blocked structural ability X
ctor/term collision X.x
Tip: Use `help filestatus` to learn more.
```
This should fail with a ctor/term conflict.
``` ucm
2024-07-01 20:28:52 +03:00
scratch/main2> add
2022-01-21 00:39:22 +03:00
x These definitions failed:
Reason
blocked structural ability X
ctor/term collision X.x
Tip: Use `help filestatus` to learn more.
```