From 5bc33247eeba8166b3dd0b7b5fa60f89e9b8dc05 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 22 Nov 2023 16:31:05 -0500 Subject: [PATCH 1/2] initial failing transcript --- .../transcripts/update-type-add-new-record.md | 14 ++++++ .../update-type-add-new-record.output.md | 45 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 unison-src/transcripts/update-type-add-new-record.md create mode 100644 unison-src/transcripts/update-type-add-new-record.output.md 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..6ac9955ddf --- /dev/null +++ b/unison-src/transcripts/update-type-add-new-record.md @@ -0,0 +1,14 @@ +```ucm:hide +.lib> builtins.merge +``` + +```unison +unique type Foo = { bar : Nat } +``` + +This shouldn't be an error. + +```ucm:error +.> 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..73961f6a21 --- /dev/null +++ b/unison-src/transcripts/update-type-add-new-record.output.md @@ -0,0 +1,45 @@ +```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 + +``` +This shouldn't be an error. + +```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... + + 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. + +.> view Foo + + ⚠️ + + The following names were not found in the codebase. Check your spelling. + Foo + +``` From 5c5f8f5ce80d542aa19190e2271ffefc1e00b894 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 27 Nov 2023 22:12:03 -0500 Subject: [PATCH 2/2] 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 } ```