haskell / haskell-language-server

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

ghcide (hls) fails silently on GHC source for syntax error in Parser.y #739

Closed alanz closed 3 years ago

alanz commented 4 years ago

If I have a Syntax error in Parser.y, and I start up editing another haskell file (e.g. PostProcess.hs), there is not indication that there is a problem, but no IDE features work.

haskell-language-server version: 0.4.0.0 (GHC: 8.10.2) (PATH: /home/alanz/.cabal/store/ghc-8.10.2/haskell-language-server-0.4.0.0-fcf5c0f6f7e48d6f1ff5bf93db6740dd2802d350d47626e63386f528aa8caaa3/bin/haskell-language-server)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "importLens",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /home/alanz/mysrc/git.haskell.org/ghc
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.04s
Output from setting up the cradle Cradle {cradleRootDir = "/home/alanz/mysrc/git.haskell.org/ghc", cradleOptsProg = CradleAction: Bios}
> compiler/GHC/Parser.y:3004: lexical error before `.'
> hadrian: Error when running Shake build system:
>   at want, called at src/Main.hs:102:30 in main:Main
> * Depends on: tool:/home/alanz/mysrc/git.haskell.org/ghc/compiler/GHC/Parser/PostProcess.hs
>   at need, called at src/Rules/ToolArgs.hs:71:5 in main:Rules.ToolArgs
> * Depends on: .hie-bios/stage0/compiler/build/GHC/Parser.hs
>   at cmd', called at src/Builder.hs:293:23 in main:Builder
>   at cmd, called at src/Builder.hs:380:8 in main:Builder
> * Raised the exception:
> Development.Shake.cmd, system command failed
> Command line: /home/alanz/.cabal/bin/happy -agc --strict compiler/GHC/Parser.y -o .hie-bios/stage0/compiler/build/GHC/Parser.hs
> Exit code: 1
> Stderr and Stdout:
> compiler/GHC/Parser.y:3004: lexical error before `.'
> 
> 
Output from setting up the cradle Cradle {cradleRootDir = "/home/alanz/mysrc/git.haskell.org/ghc", cradleOptsProg = CradleAction: Bios}
> compiler/GHC/Parser.y:3004: lexical error before `.'
> hadrian: Error when running Shake build system:
>   at want, called at src/Main.hs:102:30 in main:Main
> * Depends on: tool:/home/alanz/mysrc/git.haskell.org/ghc/compiler/GHC/Parser/Header.hs
>   at need, called at src/Rules/ToolArgs.hs:71:5 in main:Rules.ToolArgs
> * Depends on: .hie-bios/stage0/compiler/build/GHC/Parser.hs
>   at cmd', called at src/Builder.hs:293:23 in main:Builder
>   at cmd, called at src/Builder.hs:380:8 in main:Builder
> * Raised the exception:
> Development.Shake.cmd, system command failed
> Command line: /home/alanz/.cabal/bin/happy -agc --strict compiler/GHC/Parser.y -o .hie-bios/stage0/compiler/build/GHC/Parser.hs
> Exit code: 1
> Stderr and Stdout:
> compiler/GHC/Parser.y:3004: lexical error before `.'
> 
> 
ndmitchell commented 4 years ago

Was the error in the .y file present before you started editing? In general, I think changes to .y files will be entirely ignored other than when starting. Maybe hie-bios should we equipped with the command to regenerate .hs files and that knowledge, if we want to support .y files.

wz1000 commented 4 years ago

I don't think the issue is with .y files(ghcide ignores them completely), it's with the fact that the cradle failure wasn't reported as a diagnostic.

alanz commented 4 years ago

Was the error in the .y file present before you started editing?

Yes. I had actually deliberately put an error in the .y file as a reminder where to carry on for my next work session on GHC. So this was a fresh startup of my IDE, where I loaded PostProcess.hs to warm up HLS, as I normally do. And basically nothing happened, visibly.

pepeiborra commented 3 years ago

I think ghcide has become better at reporting cradle failures. @alanz would you care to test this again?

alanz commented 3 years ago

I just tested this, it does now report the error.

Thanks.