From e9c2d4957c1988b23defd55e61a081128f89b8ff Mon Sep 17 00:00:00 2001 From: Mitchell Rosen Date: Fri, 30 Aug 2024 14:25:21 -0400 Subject: [PATCH] fix suffixification logic in update --- .../Codebase/Editor/HandleInput/Update2.hs | 10 +++++---- unison-src/transcripts/fix-5276.md | 2 +- unison-src/transcripts/fix-5276.output.md | 22 ++----------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs index 71ee1483bf..b8a96f0141 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs @@ -325,16 +325,18 @@ makePPE :: Names -> DefnsF (Map Name) TermReferenceId TypeReferenceId -> PrettyPrintEnvDecl -makePPE hashLen names initialFileNames dependents = +makePPE hashLen namespaceNames initialFileNames dependents = PPED.addFallback - (PPED.makeFilePPED (initialFileNames <> Names.fromUnconflictedReferenceIds dependents)) + ( let names = initialFileNames <> Names.fromUnconflictedReferenceIds dependents + in PPED.makePPED (PPE.namer names) (PPE.suffixifyByName (Names.shadowing names namespaceNames)) + ) ( PPED.makePPED - (PPE.hqNamer hashLen names) + (PPE.hqNamer hashLen namespaceNames) -- We don't want to over-suffixify for a reference in the namespace. For example, say we have "foo.bar" in the -- namespace and "oink.bar" in the file. "bar" may be a unique suffix among the namespace names, but would be -- ambiguous in the context of namespace + file names. -- -- So, we use `shadowing`, which starts with the LHS names (the namespace), and adds to it names from the -- RHS (the initial file names, i.e. what was originally saved) that don't already exist in the LHS. - (PPE.suffixifyByHash (Names.shadowing names initialFileNames)) + (PPE.suffixifyByHash (Names.shadowing namespaceNames initialFileNames)) ) diff --git a/unison-src/transcripts/fix-5276.md b/unison-src/transcripts/fix-5276.md index 0d4f580b05..e1d5c22230 100644 --- a/unison-src/transcripts/fix-5276.md +++ b/unison-src/transcripts/fix-5276.md @@ -19,6 +19,6 @@ scratch/main> add x = 100 ``` -```ucm:error +```ucm scratch/main> update ``` diff --git a/unison-src/transcripts/fix-5276.output.md b/unison-src/transcripts/fix-5276.output.md index 0dafb981ea..163079a7c2 100644 --- a/unison-src/transcripts/fix-5276.output.md +++ b/unison-src/transcripts/fix-5276.output.md @@ -66,26 +66,8 @@ scratch/main> update That's done. Now I'm making sure everything typechecks... - Typechecking failed. I've updated your scratch file with the - definitions that need fixing. Once the file is compiling, try - `update` again. + Everything typechecks, so I'm saving the results... -``` -``` unison:added-by-ucm scratch.u -x = 100 - --- The definitions below no longer typecheck with the changes above. --- Please fix the errors and try `update` again. - -b.y : Nat -b.y = - use Nat + - x + 1 - -c : Nat -c = - use Nat + - y + 1 + Done. ``` -