diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Upgrade.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Upgrade.hs index 3d40d9c972..61c7cdaf7e 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Upgrade.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Upgrade.hs @@ -192,13 +192,13 @@ handleUpgrade oldDepName newDepName = do maybePath <- if isTranscript then pure Nothing - else do + else fmap Just do maybeLatestFile <- Cli.getLatestFile - case maybeLatestFile of - Nothing -> pure (Just "scratch.u") - Just (file, _) -> pure (Just file) + pure case maybeLatestFile of + Nothing -> "scratch.u" + Just (file, _) -> file Cli.respond (Output.DisplayDefinitionsString maybePath prettyUnisonFile) - Cli.respond (Output.UpgradeFailure oldDepName newDepName) + Cli.respond (Output.UpgradeFailure (fromMaybe "scratch.u" maybePath) oldDepName newDepName) Cli.returnEarlyWithoutOutput branchUpdates <- diff --git a/unison-cli/src/Unison/Codebase/Editor/Output.hs b/unison-cli/src/Unison/Codebase/Editor/Output.hs index 84dc4e3f8d..cb456e1d47 100644 --- a/unison-cli/src/Unison/Codebase/Editor/Output.hs +++ b/unison-cli/src/Unison/Codebase/Editor/Output.hs @@ -389,7 +389,7 @@ data Output | UpdateTypecheckingFailure | UpdateTypecheckingSuccess | UpdateIncompleteConstructorSet UpdateOrUpgrade Name (Map ConstructorId Name) (Maybe Int) - | UpgradeFailure !NameSegment !NameSegment + | UpgradeFailure !FilePath !NameSegment !NameSegment | UpgradeSuccess !NameSegment !NameSegment data UpdateOrUpgrade = UOUUpdate | UOUUpgrade diff --git a/unison-cli/src/Unison/CommandLine/OutputMessages.hs b/unison-cli/src/Unison/CommandLine/OutputMessages.hs index d92ac20ea0..eb3ed5668b 100644 --- a/unison-cli/src/Unison/CommandLine/OutputMessages.hs +++ b/unison-cli/src/Unison/CommandLine/OutputMessages.hs @@ -2183,12 +2183,14 @@ notifyUser dir = \case <> operationName <> "again." ] - UpgradeFailure old new -> + UpgradeFailure path old new -> pure . P.wrap $ "I couldn't automatically upgrade" <> P.text (NameSegment.toText old) <> "to" <> P.group (P.text (NameSegment.toText new) <> ".") + <> "However, I've added the definitions that need attention to the top of" + <> P.group (prettyFilePath path <> ".") UpgradeSuccess old new -> pure . P.wrap $ "I upgraded" diff --git a/unison-src/transcripts/fix4482.output.md b/unison-src/transcripts/fix4482.output.md index 80d9cf9434..e4add34f0a 100644 --- a/unison-src/transcripts/fix4482.output.md +++ b/unison-src/transcripts/fix4482.output.md @@ -57,6 +57,8 @@ myproj/main> upgrade foo0 foo1 use lib.foo0.lib.bonk1 bar ##Nat.+ bar bar - I couldn't automatically upgrade foo0 to foo1. + I couldn't automatically upgrade foo0 to foo1. However, I've + added the definitions that need attention to the top of + scratch.u. ``` diff --git a/unison-src/transcripts/upgrade-sad-path.output.md b/unison-src/transcripts/upgrade-sad-path.output.md index 448c6f2d27..2a86de1563 100644 --- a/unison-src/transcripts/upgrade-sad-path.output.md +++ b/unison-src/transcripts/upgrade-sad-path.output.md @@ -37,6 +37,8 @@ proj/main> upgrade old new use Nat + foo + 10 - I couldn't automatically upgrade old to new. + I couldn't automatically upgrade old to new. However, I've + added the definitions that need attention to the top of + scratch.u. ```