Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unsigned int error in update #4434

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Contributor Author

@aryairani aryairani Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was somehow counting up from [0 .. unsigned(-1)] instead of [0 .. -1] and then quietly failing the all.

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
12 changes: 12 additions & 0 deletions unison-src/transcripts/update-type-add-new-record.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```ucm:hide
.lib> builtins.merge
```

```unison
unique type Foo = { bar : Nat }
```

```ucm
.> update
.> view Foo
```
35 changes: 35 additions & 0 deletions unison-src/transcripts/update-type-add-new-record.output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```unison
unique type Foo = { bar : Nat }
```

```ucm

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`:

unique type Foo
Foo.bar : Foo -> Nat
Foo.bar.modify : (Nat ->{g} Nat) -> Foo ->{g} Foo
Foo.bar.set : Nat -> Foo -> Foo

```
```ucm
.> update

Okay, I'm searching the branch for code that needs to be
updated...

That's done. Now I'm making sure everything typechecks...

Everything typechecks, so I'm saving the results...

Done.

.> view Foo

unique type Foo = { bar : Nat }

```
Loading