Description
I believe the partial record selection here:
TyClD _ x ->
let generalCompls = [mkComp id cl (Just $ ppr $ tcdLName x)
| id <- listify (\(_ :: Located(IdP GhcPs)) -> True) x
(line 449, ghcide/src/Development/IDE/Plugin/Completions/Logic.hs)
is failing when HLS tries to do name completion for a type family.
Commenting out the entire "TcClD _ x" case avoids the crash.
C.f. https://hackage.haskell.org/package/ghc-8.10.2/docs/src/GHC.Hs.Decls.html#TyClDecl
(That's 8.10.2 documentation, not sure how much it matters.)
The FamDecl and XTyClDecl data constructors don't have a field tcdLName.
The ClassDecl constructor doesn't have that field either, but the ClassDecl case is handled separately.
C.f. a03013c
Your environment
haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /home/peter/.ghcup/bin/haskell-language-server-wrapper-1.5.0) (GIT hash: 311107eabbf0537e0c192b2c377d282505b4eff1)
Tool versions found on the $PATH
cabal: 3.6.2.0
stack: 2.7.3
ghc: 8.10.7
(I can also replicate the crash on a fresh build of master.)
Ubuntu
emacs
minimal example script provided
Steps to reproduce
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module MyLib where
type family Baaaar (bool :: Bool) a where
Baaaar _ _ = Bool
class Foo a where
foo :: a
foo = Baa -- cursor here, wait for completion.
Expected behaviour
Should see hover text and completions and other HLS stuff.
Actual behaviour
HLS crashes with:
haskell-language-server-8.10.7: No match in record selector tcdLName
Include debug information
Debug output:
peter@gtower:~/Notes/2021november21_optionals$ haskell-language-server-wrapper --debug .
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.5.0.0, Git revision 311107eabbf0537e0c192b2c377d282505b4eff1 (dirty) x86_64 ghc-8.10.7
Current directory: /home/peter/Notes/2021november21_optionals
Operating system: linux
Arguments: ["--debug","."]
Cradle directory: /home/peter/Notes/2021november21_optionals
Cradle type: Cabal
Tool versions found on the $PATH
cabal: 3.6.2.0
stack: 2.7.3
ghc: 8.10.7
Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"]
Launching haskell-language-server exe at:/home/peter/.ghcup/bin/haskell-language-server-8.10.7
haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /home/peter/.ghcup/bin/haskell-language-server-8.10.7~1.5.0) (GIT hash: 311107eabbf0537e0c192b2c377d282505b4eff1)
ghcide setup tester in /home/peter/Notes/2021november21_optionals.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Step 1/4: Finding files to test in /home/peter/Notes/2021november21_optionals
Found 1 files
Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
()
Step 3/4: Initializing the IDE
2021-11-25 17:23:28.234619634 [ThreadId 7] DEBUG hls: Initializing exports map from hiedb
Step 4/4: Type checking the files
2021-11-25 17:23:28.235786801 [ThreadId 7] DEBUG hls: Done initializing exports map from hiedb (3)
2021-11-25 17:23:28.237470407 [ThreadId 25] INFO hls: Consulting the cradle for "src/MyLib.hs"
2021-11-25 17:23:28.23761194 [ThreadId 25] WARNING hls: No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src/MyLib.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2021-11-25 17:23:28.250590547 [ThreadId 25] DEBUG hls: Output from setting up the cradle Cradle {cradleRootDir = "/home/peter/Notes/2021november21_optionals", cradleOptsProg = CradleAction: Cabal}
2021-11-25 17:23:28.274789453 [ThreadId 31] INFO hie-bios: Build profile: -w ghc-8.10.7 -O1
2021-11-25 17:23:28.274915898 [ThreadId 31] INFO hie-bios: In order, the following will be built (use -v for more details):
2021-11-25 17:23:28.275013091 [ThreadId 31] INFO hie-bios: - 2021november21-optionals-0.1.0.0 (lib) (first run)
2021-11-25 17:23:28.302123586 [ThreadId 31] INFO hie-bios: Preprocessing library for 2021november21-optionals-0.1.0.0..
2021-11-25 17:23:28.384920381 [ThreadId 25] DEBUG hls: Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-odir","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-hidir","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-stubdir","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-i","-i/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-isrc","-i/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build/autogen","-i/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build/global-autogen","-I/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build/autogen","-I/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build/global-autogen","-I/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build","-optP-include","-optP/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","2021november21-optionals-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/home/peter/.cabal/store/ghc-8.10.7/package.db","-package-db","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/packagedb/ghc-8.10.7","-package-db","/home/peter/.cache/hie-bios/dist-2021november21_optionals-f5fd6f1183233be36fa1372464222337/build/x86_64-linux/ghc-8.10.7/2021november21-optionals-0.1.0.0/package.conf.inplace","-package-id","base-4.14.3.0","-XHaskell2010","MyLib","-hide-all-packages","-haddock"], componentRoot = "/home/peter/Notes/2021november21_optionals", componentDependencies = ["2021november21-optionals.cabal","cabal.project","cabal.project.local"]},"/home/peter/.ghcup/ghc/8.10.7/lib/ghc-8.10.7")
2021-11-25 17:23:28.548727293 [ThreadId 25] INFO hls: Using interface files cache dir: /home/peter/.cache/ghcide/2021november21-optionals-0.1.0.0-inplace-a89adf64f9c592470e44b6e191dd8380ce986955
2021-11-25 17:23:28.549006151 [ThreadId 25] INFO hls: Making new HscEnv[2021november21-optionals-0.1.0.0-inplace]
2021-11-25 17:23:28.66209177 [ThreadId 25] DEBUG hls: New Component Cache HscEnvEq: (([],Just HscEnvEq 5),fromList [("2021november21-optionals.cabal",Just 2021-11-21 18:19:45.787970905 UTC),("cabal.project",Nothing),("cabal.project.local",Nothing)])
2021-11-25 17:23:28.663824815 [ThreadId 25] DEBUG hls: Known files updated: fromList [(TargetFile NormalizedFilePath "/home/peter/Notes/2021november21_optionals/src/MyLib.hs",fromList ["/home/peter/Notes/2021november21_optionals/src/MyLib.hs"]),(TargetModule MyLib,fromList ["/home/peter/Notes/2021november21_optionals/src/MyLib.hs"])]
2021-11-25 17:23:28.663954289 [ThreadId 25] DEBUG hls: Restarting build session due to new component for keys [GetKnownTargets; ,GhcSessionIO; ] (aborting the previous one took 0.00s)
2021-11-25 17:23:28.664163788 [ThreadId 45] DEBUG hls: hlint:getIdeas:file:NormalizedFilePath "/home/peter/Notes/2021november21_optionals/src/MyLib.hs"
2021-11-25 17:23:28.664029682 [ThreadId 10] DEBUG hls: Finishing build session(exception: AsyncCancelled)
2021-11-25 17:23:28.871884361 [ThreadId 61] INFO hls: File: /home/peter/Notes/2021november21_optionals/src/MyLib.hs
Hidden: no
Range: 11:9-11:12
Source: typecheck
Severity: DsError
Message: Data constructor not in scope: Baa
2021-11-25 17:23:28.872753301 [ThreadId 55] INFO hls: finish: User TypeCheck (took 0.21s)
2021-11-25 17:23:28.87371238 [ThreadId 110] INFO hls: finish: GetHie (took 0.00s)
2021-11-25 17:23:28.873986618 [ThreadId 112] INFO hls: finish: GenerateCore (took 0.00s)
Completed (1 file worked, 0 files failed)
Paste the logs from the lsp-client, e.g. for VS Code
LSP logs:
Process lsp-haskell stderr finished
Module "/home/peter/Notes/2021november21_optionals/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/peter/Notes/2021november21_optionals", cradleOptsProg = CradleAction: Cabal}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.4.0.0, Git revision 0a18edde24923251a148cbbc0ae993a6aac83b9c (dirty) x86_64 ghc-8.10.1
Current directory: /home/peter/Notes/2021november21_optionals
Operating system: linux
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /home/peter/Notes/2021november21_optionals
Cradle type: Cabal
Tool versions found on the $PATH
cabal: 3.6.2.0
stack: 2.5.1
ghc: 8.10.7
Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server-8.10","haskell-language-server"]
Launching haskell-language-server exe at:/home/peter/.ghcup/bin/haskell-language-server-8.10.7
haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /home/peter/.ghcup/bin/haskell-language-server-8.10.7~1.5.0) (GIT hash: 311107eabbf0537e0c192b2c377d282505b4eff1)
Starting (haskell-language-server)LSP server...
with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"]
in directory: /home/peter/Notes/2021november21_optionals
haskell-language-server-8.10.7: No match in record selector tcdLName