Skip to content

Commit

Permalink
fix suffixification logic in update
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Aug 30, 2024
1 parent 66d70b3 commit e9c2d49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
10 changes: 6 additions & 4 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
2 changes: 1 addition & 1 deletion unison-src/transcripts/fix-5276.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ scratch/main> add
x = 100
```

```ucm:error
```ucm
scratch/main> update
```
22 changes: 2 additions & 20 deletions unison-src/transcripts/fix-5276.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```

0 comments on commit e9c2d49

Please sign in to comment.