-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: update no longer tries to put non-test watches into the namespace #4454
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,10 +99,7 @@ handleUpdate2 :: Cli () | |
handleUpdate2 = do | ||
Cli.Env {codebase} <- ask | ||
tuf <- Cli.expectLatestTypecheckedFile | ||
|
||
-- - get add/updates from TUF | ||
let termAndDeclNames :: Defns (Set Name) (Set Name) = getTermAndDeclNames tuf | ||
|
||
let termAndDeclNames = getTermAndDeclNames tuf | ||
currentPath <- Cli.getCurrentPath | ||
currentBranch0 <- Cli.getBranch0At currentPath | ||
let namesIncludingLibdeps = Branch.toNames currentBranch0 | ||
|
@@ -197,9 +194,10 @@ saveTuf :: (Name -> Either Output [Name]) -> TypecheckedUnisonFile Symbol Ann -> | |
saveTuf getConstructors tuf = do | ||
Cli.Env {codebase} <- ask | ||
currentPath <- Cli.getCurrentPath | ||
branchUpdates <- Cli.runTransactionWithRollback \abort -> do | ||
Codebase.addDefsToCodebase codebase tuf | ||
typecheckedUnisonFileToBranchUpdates abort getConstructors tuf | ||
branchUpdates <- | ||
Cli.runTransactionWithRollback \abort -> do | ||
Codebase.addDefsToCodebase codebase tuf | ||
typecheckedUnisonFileToBranchUpdates abort getConstructors tuf | ||
Cli.stepAt "update" (Path.unabsolute currentPath, Branch.batchUpdates branchUpdates) | ||
|
||
-- @typecheckedUnisonFileToBranchUpdates getConstructors file@ returns a list of branch updates (suitable for passing | ||
|
@@ -257,11 +255,14 @@ typecheckedUnisonFileToBranchUpdates abort getConstructors tuf = do | |
tuf | ||
& UF.hashTermsId | ||
& Map.toList | ||
& foldMap \(var, (_, ref, _, _, _)) -> | ||
let split = splitVar var | ||
in [ BranchUtil.makeAnnihilateTermName split, | ||
BranchUtil.makeAddTermName split (Referent.fromTermReferenceId ref) Map.empty | ||
] | ||
& foldMap \(var, (_, ref, wk, _, _)) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the bugfix. before, we didn't look at |
||
if WK.watchKindShouldBeStoredInDatabase wk | ||
then | ||
let split = splitVar var | ||
in [ BranchUtil.makeAnnihilateTermName split, | ||
BranchUtil.makeAddTermName split (Referent.fromTermReferenceId ref) Map.empty | ||
] | ||
else [] | ||
|
||
splitVar :: Symbol -> Path.Split | ||
splitVar = Path.splitFromName . Name.unsafeFromVar | ||
|
@@ -425,10 +426,17 @@ incrementLastSegmentChar (ForwardName segments) = | |
else Text.init text `Text.append` Text.singleton (succ $ Text.last text) | ||
in NameSegment incrementedText | ||
|
||
-- @getTermAndDeclNames file@ returns the names of the terms and decls defined in a typechecked Unison file. | ||
getTermAndDeclNames :: (Var v) => TypecheckedUnisonFile v a -> Defns (Set Name) (Set Name) | ||
getTermAndDeclNames tuf = Defns (terms <> effectCtors <> dataCtors) (effects <> datas) | ||
getTermAndDeclNames tuf = | ||
Defns (terms <> effectCtors <> dataCtors) (effects <> datas) | ||
where | ||
terms = keysToNames $ UF.hashTermsId tuf | ||
terms = | ||
UF.hashTermsId tuf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there was a similar issue here in just extracting type/term names; I'm not sure if it directly contributed to the crash, but we simply don't want watches that aren't "test" watches here, either. |
||
& Map.foldMapWithKey \var (_, _, wk, _, _) -> | ||
if WK.watchKindShouldBeStoredInDatabase wk | ||
then Set.singleton (Name.unsafeFromVar var) | ||
else Set.empty | ||
effects = keysToNames $ UF.effectDeclarationsId' tuf | ||
datas = keysToNames $ UF.dataDeclarationsId' tuf | ||
effectCtors = foldMap ctorsToNames $ fmap (Decl.toDataDecl . snd) $ UF.effectDeclarationsId' tuf | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```unison | ||
> 1 | ||
``` | ||
|
||
```ucm | ||
.> update | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
```unison | ||
> 1 | ||
``` | ||
|
||
```ucm | ||
✅ | ||
scratch.u changed. | ||
Now evaluating any watch expressions (lines starting with | ||
`>`)... Ctrl+C cancels. | ||
1 | > 1 | ||
⧩ | ||
1 | ||
``` | ||
```ucm | ||
.> update | ||
Okay, I'm searching the branch for code that needs to be | ||
updated... | ||
Done. | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor, no change in behavior