mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
⅄ trunk → 24-07-01-todo-merge-precondition-violations
This commit is contained in:
commit
8ff7e6d92d
@ -81,7 +81,11 @@ identifierSplitAtPosition uri pos = do
|
|||||||
vf <- getVirtualFile uri
|
vf <- getVirtualFile uri
|
||||||
PosPrefixInfo {fullLine, cursorPos} <- MaybeT (VFS.getCompletionPrefix pos vf)
|
PosPrefixInfo {fullLine, cursorPos} <- MaybeT (VFS.getCompletionPrefix pos vf)
|
||||||
let (before, after) = Text.splitAt (cursorPos ^. character . to fromIntegral) fullLine
|
let (before, after) = Text.splitAt (cursorPos ^. character . to fromIntegral) fullLine
|
||||||
pure (Text.takeWhileEnd isIdentifierChar before, Text.takeWhile isIdentifierChar after)
|
pure
|
||||||
|
( Text.takeWhileEnd isIdentifierChar before,
|
||||||
|
-- names can end with '!', and it's not a force, so we include it in the identifier if it's at the end.
|
||||||
|
Text.takeWhile (\c -> isIdentifierChar c || c == '!') after
|
||||||
|
)
|
||||||
where
|
where
|
||||||
isIdentifierChar c =
|
isIdentifierChar c =
|
||||||
-- Manually exclude '!' and apostrophe, since those are usually just forces and
|
-- Manually exclude '!' and apostrophe, since those are usually just forces and
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
https://github.com/unisonweb/unison/issues/2786
|
https://github.com/unisonweb/unison/issues/2786
|
||||||
|
|
||||||
```ucm:hide
|
```ucm:hide
|
||||||
.ns> builtins.merge
|
scratch/main> builtins.merge lib.builtins
|
||||||
```
|
```
|
||||||
|
|
||||||
First we add an ability to the codebase.
|
First we add an ability to the codebase.
|
||||||
@ -15,7 +15,7 @@ unique ability Channels where
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> add
|
scratch/main> add
|
||||||
```
|
```
|
||||||
|
|
||||||
Now we update the ability, changing the name of the constructor, _but_, we simultaneously
|
Now we update the ability, changing the name of the constructor, _but_, we simultaneously
|
||||||
@ -36,8 +36,8 @@ thing _ = send 1
|
|||||||
These should fail with a term/ctor conflict since we exclude the ability from the update.
|
These should fail with a term/ctor conflict since we exclude the ability from the update.
|
||||||
|
|
||||||
```ucm:error
|
```ucm:error
|
||||||
.ns> update.old patch Channels.send
|
scratch/main> update.old patch Channels.send
|
||||||
.ns> update.old patch thing
|
scratch/main> update.old patch thing
|
||||||
```
|
```
|
||||||
|
|
||||||
If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.
|
If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.
|
||||||
@ -56,20 +56,20 @@ thing _ = send 1
|
|||||||
These updates should succeed since `Channels` is a dependency.
|
These updates should succeed since `Channels` is a dependency.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> update.old.preview patch Channels.send
|
scratch/main> update.old.preview patch Channels.send
|
||||||
.ns> update.old.preview patch thing
|
scratch/main> update.old.preview patch thing
|
||||||
```
|
```
|
||||||
|
|
||||||
We should also be able to successfully update the whole thing.
|
We should also be able to successfully update the whole thing.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> update.old
|
scratch/main> update.old
|
||||||
```
|
```
|
||||||
|
|
||||||
# Constructor-term conflict
|
# Constructor-term conflict
|
||||||
|
|
||||||
```ucm:hide
|
```ucm:hide
|
||||||
.ns2> builtins.merge
|
scratch/main2> builtins.merge lib.builtins
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ X.x = 1
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns2> add
|
scratch/main2> add
|
||||||
```
|
```
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
@ -89,5 +89,5 @@ structural ability X where
|
|||||||
This should fail with a ctor/term conflict.
|
This should fail with a ctor/term conflict.
|
||||||
|
|
||||||
```ucm:error
|
```ucm:error
|
||||||
.ns2> add
|
scratch/main2> add
|
||||||
```
|
```
|
||||||
|
@ -24,7 +24,7 @@ unique ability Channels where
|
|||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
||||||
.ns> add
|
scratch/main> add
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ thing _ = send 1
|
|||||||
These should fail with a term/ctor conflict since we exclude the ability from the update.
|
These should fail with a term/ctor conflict since we exclude the ability from the update.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> update.old patch Channels.send
|
scratch/main> update.old patch Channels.send
|
||||||
|
|
||||||
x These definitions failed:
|
x These definitions failed:
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ These should fail with a term/ctor conflict since we exclude the ability from th
|
|||||||
|
|
||||||
Tip: Use `help filestatus` to learn more.
|
Tip: Use `help filestatus` to learn more.
|
||||||
|
|
||||||
.ns> update.old patch thing
|
scratch/main> update.old patch thing
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ thing _ = send 1
|
|||||||
These updates should succeed since `Channels` is a dependency.
|
These updates should succeed since `Channels` is a dependency.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> update.old.preview patch Channels.send
|
scratch/main> update.old.preview patch Channels.send
|
||||||
|
|
||||||
I found and typechecked these definitions in scratch.u. If you
|
I found and typechecked these definitions in scratch.u. If you
|
||||||
do an `add` or `update`, here's how your codebase would
|
do an `add` or `update`, here's how your codebase would
|
||||||
@ -135,7 +135,7 @@ These updates should succeed since `Channels` is a dependency.
|
|||||||
|
|
||||||
Channels.send : a ->{Channels} ()
|
Channels.send : a ->{Channels} ()
|
||||||
|
|
||||||
.ns> update.old.preview patch thing
|
scratch/main> update.old.preview patch thing
|
||||||
|
|
||||||
I found and typechecked these definitions in scratch.u. If you
|
I found and typechecked these definitions in scratch.u. If you
|
||||||
do an `add` or `update`, here's how your codebase would
|
do an `add` or `update`, here's how your codebase would
|
||||||
@ -153,7 +153,7 @@ These updates should succeed since `Channels` is a dependency.
|
|||||||
We should also be able to successfully update the whole thing.
|
We should also be able to successfully update the whole thing.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns> update.old
|
scratch/main> update.old
|
||||||
|
|
||||||
⊡ Ignored previously added definitions: Channels
|
⊡ Ignored previously added definitions: Channels
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ X.x = 1
|
|||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
||||||
.ns2> add
|
scratch/main2> add
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ structural ability X where
|
|||||||
This should fail with a ctor/term conflict.
|
This should fail with a ctor/term conflict.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.ns2> add
|
scratch/main2> add
|
||||||
|
|
||||||
x These definitions failed:
|
x These definitions failed:
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ f id = (id 1, id "hi")
|
|||||||
Another example, involving abilities. Here the ability-polymorphic function is instantiated with two different ability lists, `{}` and `{IO}`:
|
Another example, involving abilities. Here the ability-polymorphic function is instantiated with two different ability lists, `{}` and `{IO}`:
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
||||||
f id _ =
|
f id _ =
|
||||||
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||||
()
|
()
|
||||||
```
|
```
|
||||||
@ -34,17 +34,17 @@ Functor.map : Functor f -> (forall a b . (a -> b) -> f a -> f b)
|
|||||||
Functor.map = cases Functor f -> f
|
Functor.map = cases Functor f -> f
|
||||||
|
|
||||||
Functor.blah : Functor f -> ()
|
Functor.blah : Functor f -> ()
|
||||||
Functor.blah = cases Functor f ->
|
Functor.blah = cases Functor f ->
|
||||||
g : forall a b . (a -> b) -> f a -> f b
|
g : forall a b . (a -> b) -> f a -> f b
|
||||||
g = f
|
g = f
|
||||||
()
|
()
|
||||||
```
|
```
|
||||||
|
|
||||||
This example is similar, but involves abilities:
|
This example is similar, but involves abilities:
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
unique ability Remote t where doRemoteStuff : t ()
|
unique ability Remote t where doRemoteStuff : t ()
|
||||||
unique type Loc = Loc (forall t a . '{Remote t} a ->{Remote t} t a)
|
unique type Loc = Loc (forall t a . '{Remote t} a ->{Remote t} t a)
|
||||||
|
|
||||||
Loc.blah : Loc -> ()
|
Loc.blah : Loc -> ()
|
||||||
Loc.blah = cases Loc f ->
|
Loc.blah = cases Loc f ->
|
||||||
@ -52,20 +52,20 @@ Loc.blah = cases Loc f ->
|
|||||||
f0 = f
|
f0 = f
|
||||||
()
|
()
|
||||||
|
|
||||||
-- In this case, no annotation is needed since the lambda
|
-- In this case, no annotation is needed since the lambda
|
||||||
-- is checked against a polymorphic type
|
-- is checked against a polymorphic type
|
||||||
Loc.transform : (forall t a . '{Remote t} a -> '{Remote t} a)
|
Loc.transform : (forall t a . '{Remote t} a -> '{Remote t} a)
|
||||||
-> Loc -> Loc
|
-> Loc -> Loc
|
||||||
Loc.transform nt = cases Loc f -> Loc (a -> f (nt a))
|
Loc.transform nt = cases Loc f -> Loc (a -> f (nt a))
|
||||||
|
|
||||||
-- In this case, the annotation is needed since f' is inferred
|
-- In this case, the annotation is needed since f' is inferred
|
||||||
-- on its own it won't infer the higher-rank type
|
-- on its own it won't infer the higher-rank type
|
||||||
Loc.transform2 : (forall t a . '{Remote t} a -> '{Remote t} a)
|
Loc.transform2 : (forall t a . '{Remote t} a -> '{Remote t} a)
|
||||||
-> Loc -> Loc
|
-> Loc -> Loc
|
||||||
Loc.transform2 nt = cases Loc f ->
|
Loc.transform2 nt = cases Loc f ->
|
||||||
f' : forall t a . '{Remote t} a ->{Remote t} t a
|
f' : forall t a . '{Remote t} a ->{Remote t} t a
|
||||||
f' a = f (nt a)
|
f' a = f (nt a)
|
||||||
Loc f'
|
Loc f'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Types with polymorphic fields
|
## Types with polymorphic fields
|
||||||
@ -77,6 +77,6 @@ structural type HigherRanked = HigherRanked (forall a. a -> a)
|
|||||||
We should be able to add and view records with higher-rank fields.
|
We should be able to add and view records with higher-rank fields.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.higher_ranked> add
|
scratch/main> add
|
||||||
.higher_ranked> view HigherRanked
|
scratch/main> view HigherRanked
|
||||||
```
|
```
|
||||||
|
@ -33,8 +33,8 @@ f id = (id 1, id "hi")
|
|||||||
Another example, involving abilities. Here the ability-polymorphic function is instantiated with two different ability lists, `{}` and `{IO}`:
|
Another example, involving abilities. Here the ability-polymorphic function is instantiated with two different ability lists, `{}` and `{IO}`:
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
||||||
f id _ =
|
f id _ =
|
||||||
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||||
()
|
()
|
||||||
```
|
```
|
||||||
@ -61,7 +61,7 @@ Functor.map : Functor f -> (forall a b . (a -> b) -> f a -> f b)
|
|||||||
Functor.map = cases Functor f -> f
|
Functor.map = cases Functor f -> f
|
||||||
|
|
||||||
Functor.blah : Functor f -> ()
|
Functor.blah : Functor f -> ()
|
||||||
Functor.blah = cases Functor f ->
|
Functor.blah = cases Functor f ->
|
||||||
g : forall a b . (a -> b) -> f a -> f b
|
g : forall a b . (a -> b) -> f a -> f b
|
||||||
g = f
|
g = f
|
||||||
()
|
()
|
||||||
@ -83,11 +83,11 @@ Functor.blah = cases Functor f ->
|
|||||||
-> (∀ a b. (a -> b) -> f a -> f b)
|
-> (∀ a b. (a -> b) -> f a -> f b)
|
||||||
|
|
||||||
```
|
```
|
||||||
This example is similar, but involves abilities:
|
This example is similar, but involves abilities:
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
unique ability Remote t where doRemoteStuff : t ()
|
unique ability Remote t where doRemoteStuff : t ()
|
||||||
unique type Loc = Loc (forall t a . '{Remote t} a ->{Remote t} t a)
|
unique type Loc = Loc (forall t a . '{Remote t} a ->{Remote t} t a)
|
||||||
|
|
||||||
Loc.blah : Loc -> ()
|
Loc.blah : Loc -> ()
|
||||||
Loc.blah = cases Loc f ->
|
Loc.blah = cases Loc f ->
|
||||||
@ -95,20 +95,20 @@ Loc.blah = cases Loc f ->
|
|||||||
f0 = f
|
f0 = f
|
||||||
()
|
()
|
||||||
|
|
||||||
-- In this case, no annotation is needed since the lambda
|
-- In this case, no annotation is needed since the lambda
|
||||||
-- is checked against a polymorphic type
|
-- is checked against a polymorphic type
|
||||||
Loc.transform : (forall t a . '{Remote t} a -> '{Remote t} a)
|
Loc.transform : (forall t a . '{Remote t} a -> '{Remote t} a)
|
||||||
-> Loc -> Loc
|
-> Loc -> Loc
|
||||||
Loc.transform nt = cases Loc f -> Loc (a -> f (nt a))
|
Loc.transform nt = cases Loc f -> Loc (a -> f (nt a))
|
||||||
|
|
||||||
-- In this case, the annotation is needed since f' is inferred
|
-- In this case, the annotation is needed since f' is inferred
|
||||||
-- on its own it won't infer the higher-rank type
|
-- on its own it won't infer the higher-rank type
|
||||||
Loc.transform2 : (forall t a . '{Remote t} a -> '{Remote t} a)
|
Loc.transform2 : (forall t a . '{Remote t} a -> '{Remote t} a)
|
||||||
-> Loc -> Loc
|
-> Loc -> Loc
|
||||||
Loc.transform2 nt = cases Loc f ->
|
Loc.transform2 nt = cases Loc f ->
|
||||||
f' : forall t a . '{Remote t} a ->{Remote t} t a
|
f' : forall t a . '{Remote t} a ->{Remote t} t a
|
||||||
f' a = f (nt a)
|
f' a = f (nt a)
|
||||||
Loc f'
|
Loc f'
|
||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
@ -141,15 +141,13 @@ structural type HigherRanked = HigherRanked (forall a. a -> a)
|
|||||||
We should be able to add and view records with higher-rank fields.
|
We should be able to add and view records with higher-rank fields.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
☝️ The namespace .higher_ranked is empty.
|
scratch/main> add
|
||||||
|
|
||||||
.higher_ranked> add
|
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
structural type HigherRanked
|
structural type HigherRanked
|
||||||
|
|
||||||
.higher_ranked> view HigherRanked
|
scratch/main> view HigherRanked
|
||||||
|
|
||||||
structural type HigherRanked = HigherRanked (∀ a. a -> a)
|
structural type HigherRanked = HigherRanked (∀ a. a -> a)
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ The `merge` command merges together two branches in the same project: the curren
|
|||||||
branch. For example, to merge `topic` into `main`, switch to `main` and run `merge topic`:
|
branch. For example, to merge `topic` into `main`, switch to `main` and run `merge topic`:
|
||||||
|
|
||||||
```ucm:error
|
```ucm:error
|
||||||
.> help merge
|
scratch/main> help merge
|
||||||
.> help merge.commit
|
scratch/main> help merge.commit
|
||||||
```
|
```
|
||||||
|
|
||||||
Let's see a simple unconflicted merge in action: Alice (us) and Bob (them) add different terms. The merged result
|
Let's see a simple unconflicted merge in action: Alice (us) and Bob (them) add different terms. The merged result
|
||||||
|
@ -4,12 +4,12 @@ The `merge` command merges together two branches in the same project: the curren
|
|||||||
branch. For example, to merge `topic` into `main`, switch to `main` and run `merge topic`:
|
branch. For example, to merge `topic` into `main`, switch to `main` and run `merge topic`:
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.> help merge
|
scratch/main> help merge
|
||||||
|
|
||||||
merge
|
merge
|
||||||
`merge /branch` merges `branch` into the current branch
|
`merge /branch` merges `branch` into the current branch
|
||||||
|
|
||||||
.> help merge.commit
|
scratch/main> help merge.commit
|
||||||
|
|
||||||
merge.commit (or commit.merge)
|
merge.commit (or commit.merge)
|
||||||
`merge.commit` merges a temporary branch created by the `merge`
|
`merge.commit` merges a temporary branch created by the `merge`
|
||||||
|
@ -15,7 +15,7 @@ two.ambiguousTerm = "term two"
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.example.resolution_failures> add
|
scratch/main> add
|
||||||
```
|
```
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
@ -31,9 +31,7 @@ two.ambiguousTerm = "term two"
|
|||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
||||||
☝️ The namespace .example.resolution_failures is empty.
|
scratch/main> add
|
||||||
|
|
||||||
.example.resolution_failures> add
|
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
Updating conflicted definitions works fine.
|
Updating conflicted definitions works fine.
|
||||||
|
|
||||||
```ucm:hide
|
```ucm:hide
|
||||||
.> builtins.merge
|
scratch/main> builtins.merge lib.builtins
|
||||||
.merged> builtins.merge
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
@ -13,9 +12,9 @@ temp = 2
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.> add
|
scratch/main> add
|
||||||
.> debug.alias.term.force temp x
|
scratch/main> debug.alias.term.force temp x
|
||||||
.> delete.term temp
|
scratch/main> delete.term temp
|
||||||
```
|
```
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
@ -23,6 +22,6 @@ x = 3
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.> update
|
scratch/main> update
|
||||||
.> view x
|
scratch/main> view x
|
||||||
```
|
```
|
||||||
|
@ -22,18 +22,18 @@ temp = 2
|
|||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
||||||
.> add
|
scratch/main> add
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
temp : Nat
|
temp : Nat
|
||||||
x : Nat
|
x : Nat
|
||||||
|
|
||||||
.> debug.alias.term.force temp x
|
scratch/main> debug.alias.term.force temp x
|
||||||
|
|
||||||
Done.
|
Done.
|
||||||
|
|
||||||
.> delete.term temp
|
scratch/main> delete.term temp
|
||||||
|
|
||||||
Done.
|
Done.
|
||||||
|
|
||||||
@ -57,14 +57,14 @@ x = 3
|
|||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
||||||
.> update
|
scratch/main> update
|
||||||
|
|
||||||
Okay, I'm searching the branch for code that needs to be
|
Okay, I'm searching the branch for code that needs to be
|
||||||
updated...
|
updated...
|
||||||
|
|
||||||
Done.
|
Done.
|
||||||
|
|
||||||
.> view x
|
scratch/main> view x
|
||||||
|
|
||||||
x : Nat
|
x : Nat
|
||||||
x = 3
|
x = 3
|
||||||
|
Loading…
Reference in New Issue
Block a user