haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 367 forks source link

Internal error: unable to typecheck with invalid kind signature #3302

Open fendor opened 2 years ago

fendor commented 2 years ago

Your environment

Which OS do you use? ArchLinux Which version of GHC do you use and how did you install it? 8.10.7 How is your project built (alternative: link to the project)? default cradle

Which LSP client (editor/plugin) do you use? VSCode Which version of HLS do you use and how did you install it? 1.8.0.0 from VSCode Have you configured HLS in any way (especially: a hie.yaml file)? no

Steps to reproduce

File CoProduct.hs, note, the KindSignature is incorrect.

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module CoProduct where
import Data.Kind (Type)

type Op :: forall k l (p :: (k, l)) (j :: p) . [k -> k -> Type -> Type] -> j -> j -> Type -> Type
data Op fs p q x where
  Here :: f s t x -> Op (f : fs) (s, p) (t, q) x
  There :: Op fs s t x -> Op (f : fs) (p, s) (q, t) x

Expected behaviour

Should typecheck and produce diagnostics

Actual behaviour

Fails to typecheck and includes the following in the logs:

Logs ``` [Info - 12:27:25] Stopping the server 2022-10-24T10:27:25.950005Z | Debug | Received shutdown message Received shutdown message [Info - 12:27:25] Starting the server 2022-10-24T10:27:25.950385Z | Debug | Finished build session AsyncCancelled 2022-10-24T10:27:25.950542Z | Info | Reactor thread stopped 2022-10-24T10:27:25.959209Z | Error | Got EOF No 'hie.yaml' found. Try to discover the project type! Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.8.0.0 x86_64 ghc-9.4.2 Current directory: /home/hugin/Documents/haskell/hls-coproduct Operating system: linux Arguments: ["--lsp","--debug"] Cradle directory: /home/hugin/Documents/haskell/hls-coproduct Cradle type: Default Tool versions found on the $PATH cabal: 3.8.1.0 stack: 2.9.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"] Launching haskell-language-server exe at:/home/hugin/.ghcup/tmp/ghcup-ghc-8.10.7_cabal-3.8.1.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-8.10.7 2022-10-24T10:27:26.957414Z | Info | No log file specified; using stderr. 2022-10-24T10:27:26.957893Z | Info | haskell-language-server version: 1.8.0.0 (GHC: 8.10.7) (PATH: /home/hugin/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-8.10.7) 2022-10-24T10:27:26.958261Z | Info | Directory: /home/hugin/Documents/haskell/hls-coproduct 2022-10-24T10:27:26.958424Z | Info | Starting (haskell-language-server) LSP server... GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False} PluginIds: [ pragmas , LSPRecorderCallback , rename , ghcide-completions , stan , class , refineImports , splice , changeTypeSignature , qualifyImportedNames , alternateNumberFormat , hlint , ghcide-code-actions-fill-holes , floskell , ghcide-extend-import-action , codeRange , haddockComments , importLens , retrie , ghcide-type-lenses , ghcide-code-actions-imports-exports , ghcide-hover-and-symbols , eval , gadt , fourmolu , tactics , callHierarchy , stylish-haskell , ghcide-code-actions-type-signatures , ghcide-code-actions-bindings , moduleName , brittany , ormolu , ghcide-core , explicitFixity ] 2022-10-24T10:27:26.960736Z | Info | Logging heap statistics every 60.00s 2022-10-24T10:27:26.968423Z | Info | Starting LSP server... If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option! PluginIds: [ pragmas , LSPRecorderCallback , rename , ghcide-completions , stan , class , refineImports , splice , changeTypeSignature , qualifyImportedNames , alternateNumberFormat , hlint , ghcide-code-actions-fill-holes , floskell , ghcide-extend-import-action , codeRange , haddockComments , importLens , retrie , ghcide-type-lenses , ghcide-code-actions-imports-exports , ghcide-hover-and-symbols , eval , gadt , fourmolu , tactics , callHierarchy , stylish-haskell , ghcide-code-actions-type-signatures , ghcide-code-actions-bindings , moduleName , brittany , ormolu , ghcide-core , explicitFixity ] 2022-10-24T10:27:26.968729Z | Info | Starting server 2022-10-24T10:27:26.970346Z | Info | Started LSP server in 0.00s 2022-10-24T10:27:27.036420Z | Debug | Setting initial dynflags... 2022-10-24T10:27:27.036535Z | Debug | shouldRunSubset: True 2022-10-24T10:27:27.036603Z | Debug | Initializing exports map from hiedb 2022-10-24T10:27:27.036874Z | Info | Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-3871612185632525391) "file:///home/hugin/Documents/haskell/hls-coproduct"], clientSettings = hashed Nothing} 2022-10-24T10:27:27.038930Z | Debug | Done initializing exports map from hiedb. Size: 0 2022-10-24T10:27:27.042386Z | Debug | Shake session initialized [Info - 12:27:27] haskell-language-server version: 1.8.0.0 (GHC: 8.10.7) (PATH: /home/hugin/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-8.10.7) [Info - 12:27:27] Directory: /home/hugin/Documents/haskell/hls-coproduct [Info - 12:27:27] Starting (haskell-language-server) LSP server... GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False} PluginIds: [ pragmas , LSPRecorderCallback , rename , ghcide-completions , stan , class , refineImports , splice , changeTypeSignature , qualifyImportedNames , alternateNumberFormat , hlint , ghcide-code-actions-fill-holes , floskell , ghcide-extend-import-action , codeRange , haddockComments , importLens , retrie , ghcide-type-lenses , ghcide-code-actions-imports-exports , ghcide-hover-and-symbols , eval , gadt , fourmolu , tactics , callHierarchy , stylish-haskell , ghcide-code-actions-type-signatures , ghcide-code-actions-bindings , moduleName , brittany , ormolu , ghcide-core , explicitFixity ] [Info - 12:27:27] Logging heap statistics every 60.00s 2022-10-24T10:27:27.043026Z | Debug | Configuration changed: Object (fromList [("haskell",Object (fromList [("checkProject",Bool True),("formattingProvider",String "fourmolu"),("ghcupExecutablePath",String ""),("hlintOn",Bool False),("indentationRules",Object (fromList [("enabled",Bool True)])),("logFile",String ""),("manageHLS",String "GHCup"),("maxCompletions",Number 40.0),("metadataURL",String ""),("openDocumentationInHackage",Bool True),("openSourceInHackage",Bool True),("plugin",Object (fromList [("alternateNumberFormat",Object (fromList [("globalOn",Bool True)])),("callHierarchy",Object (fromList [("globalOn",Bool True)])),("changeTypeSignature",Object (fromList [("globalOn",Bool True)])),("class",Object (fromList [("globalOn",Bool True)])),("eval",Object (fromList [("config",Object (fromList [("diff",Bool True),("exception",Bool True)])),("globalOn",Bool True)])),("ghcide-code-actions-bindings",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-fill-holes",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-imports-exports",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-type-signatures",Object (fromList [("globalOn",Bool True)])),("ghcide-completions",Object (fromList [("config",Object (fromList [("autoExtendOn",Bool True),("snippetsOn",Bool True)])),("globalOn",Bool True)])),("ghcide-hover-and-symbols",Object (fromList [("hoverOn",Bool True),("symbolsOn",Bool True)])),("ghcide-type-lenses",Object (fromList [("config",Object (fromList [("mode",String "always")])),("globalOn",Bool True)])),("haddockComments",Object (fromList [("globalOn",Bool True)])),("hlint",Object (fromList [("codeActionsOn",Bool True),("config",Object (fromList [("flags",Array [])])),("diagnosticsOn",Bool False)])),("importLens",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True)])),("moduleName",Object (fromList [("globalOn",Bool True)])),("pragmas",Object (fromList [("codeActionsOn",Bool True),("completionOn",Bool True)])),("qualifyImportedNames",Object (fromList [("globalOn",Bool True)])),("refineImports",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True)])),("rename",Object (fromList [("config",Object (fromList [("crossModule",Bool False)])),("globalOn",Bool True)])),("retrie",Object (fromList [("globalOn",Bool True)])),("splice",Object (fromList [("globalOn",Bool True)])),("tactics",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True),("config",Object (fromList [("auto_gas",Number 4.0),("hole_severity",Null),("max_use_ctor_actions",Number 5.0),("proofstate_styling",Bool True),("timeout_duration",Number 2.0)])),("globalOn",Bool False),("hoverOn",Bool True)]))])),("promptBeforeDownloads",Bool True),("releasesDownloadStoragePath",String ""),("releasesURL",String ""),("serverEnvironment",Object (fromList [])),("serverExecutablePath",String ""),("serverExtraArgs",String "--debug "),("toolchain",Object (fromList [])),("trace",Object (fromList [("client",String "debug"),("server",String "off")])),("upgradeGHCup",Bool True)]))]) 2022-10-24T10:27:27.043525Z | Debug | Restarting build session due to config change Action Queue: [] Keys: [GetClientSettings; ] Aborting previous build session took 0.00s [Info - 12:27:27] Starting LSP server... If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option! PluginIds: [ pragmas , LSPRecorderCallback , rename , ghcide-completions , stan , class , refineImports , splice , changeTypeSignature , qualifyImportedNames , alternateNumberFormat , hlint , ghcide-code-actions-fill-holes , floskell , ghcide-extend-import-action , codeRange , haddockComments , importLens , retrie , ghcide-type-lenses , ghcide-code-actions-imports-exports , ghcide-hover-and-symbols , eval , gadt , fourmolu , tactics , callHierarchy , stylish-haskell , ghcide-code-actions-type-signatures , ghcide-code-actions-bindings , moduleName , brittany , ormolu , ghcide-core , explicitFixity ] 2022-10-24T10:27:27.043536Z | Debug | Finished build session AsyncCancelled [Info - 12:27:27] Starting server [Info - 12:27:27] Started LSP server in 0.00s 2022-10-24T10:27:27.044231Z | Debug | Set files of interest to: fromList [(NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs",Modified {firstOpen = True})] Setting initial dynflags... 2022-10-24T10:27:27.044419Z | Debug | Restarting build session due to /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs (modified) Action Queue: [] Keys: [ IsFileOfInterest; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetModificationTime; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetClientSettings; ] Aborting previous build session took 0.00s shouldRunSubset: True Initializing exports map from hiedb [Info - 12:27:27] Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-3871612185632525391) "file:///home/hugin/Documents/haskell/hls-coproduct"], clientSettings = hashed Nothing} 2022-10-24T10:27:27.044438Z | Debug | Finished build session AsyncCancelled Done initializing exports map from hiedb. Size: 0 2022-10-24T10:27:27.044812Z | Debug | Opened text document: file:///home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs Shake session initialized Configuration changed: Object (fromList [("haskell",Object (fromList [("checkProject",Bool True),("formattingProvider",String "fourmolu"),("ghcupExecutablePath",String ""),("hlintOn",Bool False),("indentationRules",Object (fromList [("enabled",Bool True)])),("logFile",String ""),("manageHLS",String "GHCup"),("maxCompletions",Number 40.0),("metadataURL",String ""),("openDocumentationInHackage",Bool True),("openSourceInHackage",Bool True),("plugin",Object (fromList [("alternateNumberFormat",Object (fromList [("globalOn",Bool True)])),("callHierarchy",Object (fromList [("globalOn",Bool True)])),("changeTypeSignature",Object (fromList [("globalOn",Bool True)])),("class",Object (fromList [("globalOn",Bool True)])),("eval",Object (fromList [("config",Object (fromList [("diff",Bool True),("exception",Bool True)])),("globalOn",Bool True)])),("ghcide-code-actions-bindings",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-fill-holes",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-imports-exports",Object (fromList [("globalOn",Bool True)])),("ghcide-code-actions-type-signatures",Object (fromList [("globalOn",Bool True)])),("ghcide-completions",Object (fromList [("config",Object (fromList [("autoExtendOn",Bool True),("snippetsOn",Bool True)])),("globalOn",Bool True)])),("ghcide-hover-and-symbols",Object (fromList [("hoverOn",Bool True),("symbolsOn",Bool True)])),("ghcide-type-lenses",Object (fromList [("config",Object (fromList [("mode",String "always")])),("globalOn",Bool True)])),("haddockComments",Object (fromList [("globalOn",Bool True)])),("hlint",Object (fromList [("codeActionsOn",Bool True),("config",Object (fromList [("flags",Array [])])),("diagnosticsOn",Bool False)])),("importLens",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True)])),("moduleName",Object (fromList [("globalOn",Bool True)])),("pragmas",Object (fromList [("codeActionsOn",Bool True),("completionOn",Bool True)])),("qualifyImportedNames",Object (fromList [("globalOn",Bool True)])),("refineImports",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True)])),("rename",Object (fromList [("config",Object (fromList [("crossModule",Bool False)])),("globalOn",Bool True)])),("retrie",Object (fromList [("globalOn",Bool True)])),("splice",Object (fromList [("globalOn",Bool True)])),("tactics",Object (fromList [("codeActionsOn",Bool True),("codeLensOn",Bool True),("config",Object (fromList [("auto_gas",Number 4.0),("hole_severity",Null),("max_use_ctor_actions",Number 5.0),("proofstate_styling",Bool True),("timeout_duration",Number 2.0)])),("globalOn",Bool False),("hoverOn",Bool True)]))])),("promptBeforeDownloads",Bool True),("releasesDownloadStoragePath",String ""),("releasesURL",String ""),("serverEnvironment",Object (fromList [])),("serverExecutablePath",String ""),("serverExtraArgs",String "--debug "),("toolchain",Object (fromList [])),("trace",Object (fromList [("client",String "debug"),("server",String "off")])),("upgradeGHCup",Bool True)]))]) Restarting build session due to config change Action Queue: [] Keys: [GetClientSettings; ] Aborting previous build session took 0.00s Finished build session AsyncCancelled Set files of interest to: fromList [(NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs",Modified {firstOpen = True})] 2022-10-24T10:27:27.045577Z | Info | Cradle path: CoProduct.hs Restarting build session due to /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs (modified) Action Queue: [] Keys: [ IsFileOfInterest; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetModificationTime; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetClientSettings; ] Aborting previous build session took 0.00s 2022-10-24T10:27:27.045760Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for CoProduct.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. Finished build session AsyncCancelled Opened text document: file:///home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs [Info - 12:27:27] Cradle path: CoProduct.hs [Warn - 12:27:27] No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for CoProduct.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. 2022-10-24T10:27:27.053883Z | Debug | Cradle: Cradle {cradleRootDir = "/home/hugin/Documents/haskell/hls-coproduct", cradleOptsProg = CradleAction: Default} Cradle: Cradle {cradleRootDir = "/home/hugin/Documents/haskell/hls-coproduct", cradleOptsProg = CradleAction: Default} 2022-10-24T10:27:27.094319Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-dynamic"], componentRoot = "/home/hugin/Documents/haskell/hls-coproduct", componentDependencies = []},"/home/hugin/.ghcup/ghc/8.10.7/lib/ghc-8.10.7") Session loading result: Right (ComponentOptions {componentOptions = ["-dynamic"], componentRoot = "/home/hugin/Documents/haskell/hls-coproduct", componentDependencies = []},"/home/hugin/.ghcup/ghc/8.10.7/lib/ghc-8.10.7") 2022-10-24T10:27:27.134842Z | Info | Interface files cache directory: /home/hugin/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda 2022-10-24T10:27:27.135352Z | Info | Making new HscEnv. In-place unit ids: [main] [Info - 12:27:27] Interface files cache directory: /home/hugin/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda [Info - 12:27:27] Making new HscEnv. In-place unit ids: [main] 2022-10-24T10:27:27.141545Z | Debug | New component cache HscEnvEq: (([],Just HscEnvEq 7),fromList []) New component cache HscEnvEq: (([],Just HscEnvEq 7),fromList []) 2022-10-24T10:27:27.141728Z | Debug | Known files updated: fromList [(TargetFile NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs",fromList ["/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs"])] Known files updated: fromList [(TargetFile NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs",fromList ["/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs"])] 2022-10-24T10:27:27.142052Z | Debug | Restarting build session due to new component Action Queue: [Outline] Keys: [ IsFileOfInterest; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetKnownTargets; , GhcSessionIO; ] Aborting previous build session took 0.00s 2022-10-24T10:27:27.142055Z | Debug | Finished build session AsyncCancelled Restarting build session due to new component Action Queue: [Outline] Keys: [ IsFileOfInterest; /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs , GetKnownTargets; , GhcSessionIO; ] Aborting previous build session took 0.00s Finished build session AsyncCancelled 2022-10-24T10:27:27.144746Z | Debug | Finished: Outline Took: 0.00s Finished: Outline Took: 0.00s 2022-10-24T10:27:27.165126Z | Debug | Finished: InitialLoad Took: 0.02s Finished: InitialLoad Took: 0.02s 2022-10-24T10:27:27.298388Z | Debug | src/Ide/Plugin/Eval/CodeLens.hs:157:15 "fp" "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs" 2022-10-24T10:27:27.298648Z | Debug | Finished: classplugin.TypeCheck Took: 0.00s src/Ide/Plugin/Eval/CodeLens.hs:157:15 "fp" "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs" 2022-10-24T10:27:27.298721Z | Debug | Finished: codeLens.TypeCheck Took: 0.00s 2022-10-24T10:27:27.298716Z | Debug | Finished: codeLens.GhcSession Took: 0.00s 2022-10-24T10:27:27.299122Z | Debug | LOOKUP PERSISTENT FOR: MinimalImports Finished: classplugin.TypeCheck Took: 0.00s 2022-10-24T10:27:27.299178Z | Debug | Finished: codeLens.GetBindings Took: 0.00s 2022-10-24T10:27:27.299214Z | Debug | LOOKUP PERSISTENT FOR: RefineImports Finished: codeLens.TypeCheck Took: 0.00s 2022-10-24T10:27:27.299433Z | Debug | Finished: ModuleName.ghcSession Took: 0.00s 2022-10-24T10:27:27.299465Z | Debug | ModuleName.SrcPaths: [/home/hugin/Documents/haskell/hls-coproduct/.] 2022-10-24T10:27:27.299560Z | Debug | Finished: Took: 0.00s Finished: codeLens.GhcSession Took: 0.00s 2022-10-24T10:27:27.299635Z | Debug | Finished: codeLens.GetGlobalBindingTypeSigs Took: 0.00s 2022-10-24T10:27:27.299724Z | Debug | Finished: RefineImports Took: 0.00s LOOKUP PERSISTENT FOR: MinimalImports 2022-10-24T10:27:27.299867Z | Debug | ModuleName.NormalisedPaths: [/home/hugin/Documents/haskell/hls-coproduct/] 2022-10-24T10:27:27.300254Z | Debug | ModuleName.AbsoluteFilePath: /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs Finished: codeLens.GetBindings Took: 0.00s 2022-10-24T10:27:27.300366Z | Debug | ModuleName.CorrectNames: [CoProduct] LOOKUP PERSISTENT FOR: RefineImports 2022-10-24T10:27:27.300485Z | Info | ModuleName.BestName: CoProduct 2022-10-24T10:27:27.300611Z | Debug | Finished: ModuleName.GetParsedModule Took: 0.00s 2022-10-24T10:27:27.300626Z | Debug | ModuleName.StatedNameMaybe: CoProduct Finished: ModuleName.ghcSession Took: 0.00s 2022-10-24T10:27:27.301091Z | Debug | Finished: eval.GetParsedModuleWithComments Took: 0.00s ModuleName.SrcPaths: [/home/hugin/Documents/haskell/hls-coproduct/.] 2022-10-24T10:27:27.301103Z | Debug | src/Ide/Plugin/Eval/CodeLens.hs:157:15 "comments" "Comments {lineComments = fromList [], blockComments = fromList [(Range {_start = Position {_line = 0, _character = 0}, _end = Position {_line = 0, _character = 27}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE RankNTypes #-}\"}),(Range {_start = Position {_line = 1, _character = 0}, _end = Position {_line = 1, _character = 41}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE StandaloneKindSignatures #-}\"}),(Range {_start = Position {_line = 2, _character = 0}, _end = Position {_line = 2, _character = 26}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE PolyKinds #-}\"}),(Range {_start = Position {_line = 3, _character = 0}, _end = Position {_line = 3, _character = 26}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE DataKinds #-}\"}),(Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 30}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE TypeOperators #-}\"})]}" Finished: Took: 0.00s Finished: codeLens.GetGlobalBindingTypeSigs Took: 0.00s Finished: RefineImports Took: 0.00s 2022-10-24T10:27:27.301567Z | Debug | src/Ide/Plugin/Eval/CodeLens.hs:157:15 "Tests" "0 tests in 5 sections 0 setups 0 lenses." ModuleName.NormalisedPaths: [/home/hugin/Documents/haskell/hls-coproduct/] 2022-10-24T10:27:27.302008Z | Debug | src/Ide/Plugin/Eval/CodeLens.hs:157:15 "tests" "0.00s" 2022-10-24T10:27:27.302126Z | Debug | src/Ide/Plugin/Eval/CodeLens.hs:157:15 "codeLens" "0.00s" ModuleName.AbsoluteFilePath: /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs 2022-10-24T10:27:27.302287Z | Warning | InternalError: Unable to typecheck ModuleName.CorrectNames: [CoProduct] [Info - 12:27:27] ModuleName.BestName: CoProduct Finished: ModuleName.GetParsedModule Took: 0.00s ModuleName.StatedNameMaybe: CoProduct Finished: eval.GetParsedModuleWithComments Took: 0.00s src/Ide/Plugin/Eval/CodeLens.hs:157:15 "comments" "Comments {lineComments = fromList [], blockComments = fromList [(Range {_start = Position {_line = 0, _character = 0}, _end = Position {_line = 0, _character = 27}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE RankNTypes #-}\"}),(Range {_start = Position {_line = 1, _character = 0}, _end = Position {_line = 1, _character = 41}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE StandaloneKindSignatures #-}\"}),(Range {_start = Position {_line = 2, _character = 0}, _end = Position {_line = 2, _character = 26}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE PolyKinds #-}\"}),(Range {_start = Position {_line = 3, _character = 0}, _end = Position {_line = 3, _character = 26}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE DataKinds #-}\"}),(Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 30}},RawBlockComment {getRawBlockComment = \"{-# LANGUAGE TypeOperators #-}\"})]}" src/Ide/Plugin/Eval/CodeLens.hs:157:15 "Tests" "0 tests in 5 sections 0 setups 0 lenses." src/Ide/Plugin/Eval/CodeLens.hs:157:15 "tests" "0.00s" src/Ide/Plugin/Eval/CodeLens.hs:157:15 "codeLens" "0.00s" [Warn - 12:27:27] InternalError: Unable to typecheck ```

Debug information

Logs from `haskell-language-server --debug CoProduct.hs` ```bash $ haskell-language-server --debug CoProduct.hs 2022-10-24T10:29:01.347076Z | Info | No log file specified; using stderr. 2022-10-24T10:29:01.347463Z | Info | haskell-language-server version: 1.8.0.0 (GHC: 8.10.7) (PATH: /home/hugin/.cabal/store/ghc-8.10.7/haskell-language-server-1.8.0.0-e-haskell-language-server-a65505c64a3ec6497bc673538f88db67b0659eea828ba567bfeae3a43c07f7b8/bin/haskell-language-server) 2022-10-24T10:29:01.348115Z | Info | Directory: /home/hugin/Documents/haskell/hls-coproduct 2022-10-24T10:29:01.348330Z | Info | Logging heap statistics every 60.00s ghcide setup tester in /home/hugin/Documents/haskell/hls-coproduct. Report bugs at https://github.com/haskell/haskell-language-server/issues Step 1/4: Finding files to test in /home/hugin/Documents/haskell/hls-coproduct Found 1 files Step 2/4: Looking for hie.yaml files that control setup Found 1 cradle () Step 3/4: Initializing the IDE 2022-10-24T10:29:01.350839Z | Debug | Initializing exports map from hiedb 2022-10-24T10:29:01.351119Z | Debug | Shake session initialized Step 4/42022-10-24T10:29:01.351345Z | Debug | Done initializing exports map from hiedb. Size: 0 : Type checking the files 2022-10-24T10:29:01.352350Z | Info | Cradle path: CoProduct.hs 2022-10-24T10:29:01.352457Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for CoProduct.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. 2022-10-24T10:29:01.360627Z | Debug | Cradle: Cradle {cradleRootDir = "/home/hugin/Documents/haskell/hls-coproduct", cradleOptsProg = CradleAction: Default} 2022-10-24T10:29:01.397348Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-dynamic"], componentRoot = "/home/hugin/Documents/haskell/hls-coproduct", componentDependencies = []},"/home/hugin/.ghcup/ghc/8.10.7/lib/ghc-8.10.7") 2022-10-24T10:29:01.429333Z | Info | Interface files cache directory: /home/hugin/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda 2022-10-24T10:29:01.429456Z | Info | Making new HscEnv. In-place unit ids: [main] 2022-10-24T10:29:01.433918Z | Debug | New component cache HscEnvEq: (([],Just HscEnvEq 4),fromList []) 2022-10-24T10:29:01.434027Z | Debug | Known files updated: fromList [(TargetFile NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs",fromList ["/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs"])] 2022-10-24T10:29:01.434198Z | Debug | Finished build session AsyncCancelled 2022-10-24T10:29:01.434247Z | Debug | Restarting build session due to new component Action Queue: [User TypeCheck] Keys: [GetKnownTargets; , GhcSessionIO; ] Aborting previous build session took 0.00s 2022-10-24T10:29:01.434579Z | Debug | Getting hlint ideas for NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs" 2022-10-24T10:29:01.567109Z | Debug | Using extensions for NormalizedFilePath "/home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs": [ MonomorphismRestriction , RelaxedPolyRec , ForeignFunctionInterface , ImplicitPrelude , DoAndIfThenElse , PolyKinds , DataKinds , EmptyDataDecls , KindSignatures , PatternGuards , RankNTypes , TypeOperators , ExplicitNamespaces , ExplicitForAll , NondecreasingIndentation , TraditionalRecordSyntax , EmptyCase , StarIsType , StandaloneKindSignatures ] 2022-10-24T10:29:01.583243Z | Debug | Finished: User TypeCheck Took: 0.15s 2022-10-24T10:29:01.583498Z | Debug | Finished: GetHie Took: 0.00s 2022-10-24T10:29:01.583700Z | Debug | Finished: GenerateCore Took: 0.00s Files that failed: * /home/hugin/Documents/haskell/hls-coproduct/CoProduct.hs Completed (0 files worked, 1 file failed) ```
michaelpj commented 2 years ago

Looks like the TypeCheck rule is failing silently, unclear why.

googleson78 commented 2 years ago

I also encounter the same issue when I leave an operator without an operand, e.g. this causes it:

bla = 
  3 +
Ptival commented 1 year ago

Not sure whether the same problem, but I'm running into very similar error messages for code that otherwise compiles, even running haskell-language-server-wrapper manually on the command line. But in VSCode I get:

[Warn  - 3:22:19 PM] InternalError: Unable to typecheck
[Warn  - 3:23:45 PM] InternalError: ExplicitFixity: Unable to get fixity
[Warn  - 3:23:45 PM] InternalError: ExplicitFixity: Unable to get fixity
[Warn  - 3:23:46 PM] InternalError: typecheck
[Warn  - 3:23:56 PM] InternalError: Unable to typecheck

On:

[Info  - 3:22:05 PM] haskell-language-server version: 1.8.0.0 (GHC: 8.10.7) (PATH: /home/val/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-8.10.7)

EDIT: Also, sometimes it just works, so not sure why sometimes it does this.

July541 commented 1 year ago

Maybe I can answer part of this problem.

InternalError: Unable to typecheck is introduced by hls-class-plugin to indicate that the current file can't be compiled and hence no typecheck is available. It's just temporary information for incomplete code and doesn't matter if you correct your code in most situations.

HLS has many confusing internal errors just from the incomplete code, people shouldn't pay much attention to it. We should try to refactor the corresponding error message to prevent more misunderstanding.

For @fendor 's original post, it more looks like a bug from typecheck itself. I also noticed type check will work if I changed (j :: p) to any other symbol instead of p.