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 365 forks source link

Some warnings are not always displayed #577

Closed maksbotan closed 3 years ago

maksbotan commented 4 years ago

Subject of the issue

Take this file:

{-# OPTIONS_GHC -W -Wall -Wincomplete-patterns #-}

module Test where

head :: [a] -> [b]
head [] = []

I expect this to show me a warning on the last line about the not handled case. However, HLS does not show it, no matter that I've specifically enabled it.

GHC shows it of course:

[1 of 1] Compiling Test             ( test_warn.hs, test_warn.o )

test_warn.hs:6:1: warning: [-Wincomplete-patterns]
    Pattern match(es) are non-exhaustive
    In an equation for ‘head’: Patterns not matched: (_:_)
  |
6 | head [] = []
  | ^^^^^^^^^^^

Your environment

Expected behaviour

Show the warning.

Actual behaviour

Doesn't show it. Other warnings, like top-level binding with no type signature are shown.

I see this inside a cabal project as well.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output: ``` $ haskell-language-server-8.8.4 --debug test_warn.hs haskell-language-server version: 0.5.1.0 (GHC: 8.8.4) (PATH: /Users/maksbotan/.local/bin/haskell-language-server-8.8.4) (GIT hash: e3fe0e7546aa91e44cc56cfe8ec078a026cf533a) (haskell-language-server)Ghcide setup tester in /Users/maksbotan. Report bugs at https://github.com/haskell/haskell-language-server/issues Tool versions found on the $PATH cabal: 3.2.0.0 stack: 2.5.1 ghc: 8.8.4 Step 1/4: Finding files to test in /Users/maksbotan Found 1 files Step 2/4: Looking for hie.yaml files that control setup Found 1 cradle Step 3/4: Initializing the IDE Step 4/4: Type checking the files [INFO] Consulting the cradle for "test_warn.hs" NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtWarning, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for test_warn.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"}}) Output from setting up the cradle Cradle {cradleRootDir = "/Users/maksbotan", cradleOptsProg = CradleAction: Default} Loaded package environment from /Users/maksbotan/.ghc/x86_64-darwin-8.8.4/environments/default [INFO] Using interface files cache dir: /Users/maksbotan/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709 [INFO] Making new HscEnv[main] Completed (1 file worked, 0 files failed) [INFO] finish: User TypeCheck (took 0.03s) ```

LSP logs not relevant here.

georgefst commented 4 years ago

This looks like another instance of haskell/ghcide#107, which is now fixed in the version of Ghcide we're using.

jneira commented 3 years ago

@maksbotan could you confirm if warnings already displayed with an actual hls version (as it seems it should be fixed by https://github.com/haskell/haskell-language-server/issues/1083)?

jneira commented 3 years ago

closing optimistically, feel free to reopen