From ac45ebaf5c1a939277ff8fc99e936277349a7221 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Thu, 6 Jan 2022 23:54:42 +0100 Subject: [PATCH] Fix crash on completion with type family Close #2404. `tcdLName` is partial for type/data families, its a record field accessor which is not defined for all cases of the `TyClDecl` type. Instead we use `tyClDeclLName` which will look for the name through an indirection. --- ghcide/src/Development/IDE/Plugin/Completions/Logic.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index 3d9caccfa7..4032f2bc41 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -445,7 +445,7 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod | L _ (ClassOpSig _ _ ids typ) <- tcdSigs , id <- ids] TyClD _ x -> - let generalCompls = [mkComp id cl (Just $ ppr $ tcdLName x) + let generalCompls = [mkComp id cl (Just $ ppr $ tyClDeclLName x) | id <- listify (\(_ :: Located(IdP GhcPs)) -> True) x , let cl = occNameToComKind Nothing (rdrNameOcc $ unLoc id)] -- here we only have to look at the outermost type