diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs index c28d820c12..82c5af515e 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs @@ -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" diff --git a/unison-cli/src/Unison/Codebase/Editor/Output.hs b/unison-cli/src/Unison/Codebase/Editor/Output.hs index 5f1e485468..efceacd9aa 100644 --- a/unison-cli/src/Unison/Codebase/Editor/Output.hs +++ b/unison-cli/src/Unison/Codebase/Editor/Output.hs @@ -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 diff --git a/unison-cli/src/Unison/CommandLine/OutputMessages.hs b/unison-cli/src/Unison/CommandLine/OutputMessages.hs index dd4e07651c..effcf4da28 100644 --- a/unison-cli/src/Unison/CommandLine/OutputMessages.hs +++ b/unison-cli/src/Unison/CommandLine/OutputMessages.hs @@ -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." diff --git a/unison-src/transcripts/update-type-add-new-record.md b/unison-src/transcripts/update-type-add-new-record.md new file mode 100644 index 0000000000..0d311ec1e2 --- /dev/null +++ b/unison-src/transcripts/update-type-add-new-record.md @@ -0,0 +1,12 @@ +```ucm:hide +.lib> builtins.merge +``` + +```unison +unique type Foo = { bar : Nat } +``` + +```ucm +.> update +.> view Foo +``` diff --git a/unison-src/transcripts/update-type-add-new-record.output.md b/unison-src/transcripts/update-type-add-new-record.output.md new file mode 100644 index 0000000000..99980ea0cb --- /dev/null +++ b/unison-src/transcripts/update-type-add-new-record.output.md @@ -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 } + +```