From 5c5f8f5ce80d542aa19190e2271ffefc1e00b894 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 27 Nov 2023 22:12:03 -0500 Subject: [PATCH] fixed signed int issue and tweaked output message --- .../Unison/Codebase/Editor/HandleInput/Update2.hs | 4 ++-- unison-cli/src/Unison/Codebase/Editor/Output.hs | 2 +- .../src/Unison/CommandLine/OutputMessages.hs | 2 +- .../transcripts/update-type-add-new-record.md | 4 +--- .../update-type-add-new-record.output.md | 14 ++------------ 5 files changed, 7 insertions(+), 19 deletions(-) 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 index 6ac9955ddf..0d311ec1e2 100644 --- a/unison-src/transcripts/update-type-add-new-record.md +++ b/unison-src/transcripts/update-type-add-new-record.md @@ -6,9 +6,7 @@ unique type Foo = { bar : Nat } ``` -This shouldn't be an error. - -```ucm:error +```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 index 73961f6a21..99980ea0cb 100644 --- a/unison-src/transcripts/update-type-add-new-record.output.md +++ b/unison-src/transcripts/update-type-add-new-record.output.md @@ -16,8 +16,6 @@ unique type Foo = { bar : Nat } Foo.bar.set : Nat -> Foo -> Foo ``` -This shouldn't be an error. - ```ucm .> update @@ -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 Foo.` 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 } ```