Skip to content

Commit

Permalink
fixed signed int issue
Browse files Browse the repository at this point in the history
and tweaked output message
  • Loading branch information
Arya Irani committed Nov 28, 2023
1 parent 5bc3324 commit 5c5f8f5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ findCtorNames names forwardCtorNames ctorCount n =
insertShortest m _ = m
m = foldl' insertShortest mempty (Foldable.toList center)
ctorCountGuess = fromMaybe (Map.size m) ctorCount
in if Map.size m == ctorCountGuess && all (isJust . flip Map.lookup m) [0 .. fromIntegral ctorCountGuess - 1]
in if Map.size m == ctorCountGuess && all (isJust . flip Map.lookup m . fromIntegral) [0 .. ctorCountGuess - 1]
then Right $ Map.elems m
else Left $ Output.UpdateIncompleteConstructorSet n m ctorCountGuess
else Left $ Output.UpdateIncompleteConstructorSet n m ctorCount

-- Used by `findCtorNames` to filter `forwardCtorNames` to a narrow range which will be searched linearly.
-- >>> incrementLastSegmentChar $ ForwardName.fromName $ Name.unsafeFromText "foo.bar.quux"
Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/Codebase/Editor/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ data Output
| UpdateStartTypechecking
| UpdateTypecheckingFailure
| UpdateTypecheckingSuccess
| UpdateIncompleteConstructorSet Name (Map ConstructorId Name) Int
| UpdateIncompleteConstructorSet Name (Map ConstructorId Name) (Maybe Int)
| UpgradeFailure !NameSegment !NameSegment
| UpgradeSuccess !NameSegment !NameSegment

Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ notifyUser dir = \case
P.lines
[ P.wrap $
"I couldn't complete the update because I couldn't find"
<> fromString (show expectedCount)
<> fromString (maybe "" show expectedCount)
<> "constructor(s) for"
<> prettyName name
<> "where I expected to."
Expand Down
4 changes: 1 addition & 3 deletions unison-src/transcripts/update-type-add-new-record.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
unique type Foo = { bar : Nat }
```

This shouldn't be an error.

```ucm:error
```ucm
.> update
.> view Foo
```
14 changes: 2 additions & 12 deletions unison-src/transcripts/update-type-add-new-record.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ unique type Foo = { bar : Nat }
Foo.bar.set : Nat -> Foo -> Foo
```
This shouldn't be an error.

```ucm
.> update
Expand All @@ -28,18 +26,10 @@ This shouldn't be an error.
Everything typechecks, so I'm saving the results...
I couldn't complete the update because I couldn't find 0
constructor(s) for Foo where I expected to. I found: []
You can use `view Foo` and
`alias.term <hash> Foo.<ConstructorName>` to give names to
each constructor, and then try again.
Done.
.> view Foo
⚠️
The following names were not found in the codebase. Check your spelling.
Foo
unique type Foo = { bar : Nat }
```

0 comments on commit 5c5f8f5

Please sign in to comment.