Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS suggests disable deferred-type-errors (needed for type error diagnostics) #2032

Closed
bradrn opened this issue Jul 22, 2021 · 6 comments · Fixed by #2061
Closed

HLS suggests disable deferred-type-errors (needed for type error diagnostics) #2032

bradrn opened this issue Jul 22, 2021 · 6 comments · Fixed by #2061
Labels

Comments

@bradrn
Copy link
Contributor

bradrn commented Jul 22, 2021

Your environment

> haskell-language-server-wrapper.exe --probe-tools
haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: C:\Users\bradn\Documents\Haskell\hls\haskell-language-server-wrapper.exe) (GIT hash: be2071e985cb417f984ab00a1aad76dee02d6d0b)
Tool versions found on the $PATH
cabal:          2.4.1.0
stack:          2.7.1
ghc:            Not found

Which OS do you use: Windows
Which lsp-client do you use: emacs
Describe your project: stack.yaml

Contents of hie.yaml:

cradle:
  stack:
    - path: "./src/Main.hs"
      component: "supercell:exe:supercell"

Steps to reproduce

Deliberately introduce an obvious type error (e.g. by changing a signature to ()). Then run haskell-language-server typecheck, or typecheck the module in an editor.

Expected behaviour

The type error should be reported.

Actual behaviour

No type error is reported. (Interestingly, all other errors seem to be reported correctly.)

Include debug information

Debug output:

(NB. The path to the project is rather long, so for concision I have replaced it with the text <project directory>.)

Found "<project directory>\hie.yaml" for "<project directory>\a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper.exe) Version 1.2.0.0, Git revision be2071e985cb417f984ab00a1aad76dee02d6d0b (dirty) x86_64 ghc-8.10.4
Current directory: <project directory>
Operating system: mingw32
Arguments: ["--debug"]
Cradle directory: <project directory>
Cradle type: Stack

Tool versions found on the $PATH
cabal:          2.4.1.0
stack:          2.7.1
ghc:            Not found


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.4
haskell-language-server exe candidates: ["haskell-language-server-8.10.4.exe","haskell-language-server.exe"]
Launching haskell-language-server exe at:C:\Users\bradn\Documents\Haskell\hls\haskell-language-server-8.10.4.exe
haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: C:\Users\bradn\Documents\Haskell\hls\haskell-language-server-8.10.4.exe) (GIT hash: be2071e985cb417f984ab00a1aad76dee02d6d0b)
 ghcide setup tester in <project directory>.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in <project directory>
Found 2 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (<project directory>\hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-07-22 14:49:08.2145821 [ThreadId 32] DEBUG hls:    hlint:getIdeas:file:NormalizedFilePath "<project directory>\\Setup.hs"
2021-07-22 14:49:08.2145821 [ThreadId 29] DEBUG hls:    hlint:getIdeas:file:NormalizedFilePath "<project directory>\\src\\Main.hs"
2021-07-22 14:49:08.2145821 [ThreadId 37] INFO hls:     Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "<project directory>", cradleOptsProg = CradleAction: Stack}
2021-07-22 14:49:08.2302054 [ThreadId 37] DEBUG hls:    Session loading result: Left [CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Multi Cradle: No prefixes matched","pwd: <project directory>","filepath: <project directory>\\Setup.hs","prefixes:","(\"./src/Main.hs\",Stack {component = Just \"supercell:exe:supercell\", stackYaml = Nothing})"]}]
2021-07-22 14:49:08.2302054 [ThreadId 49] INFO hls:     File:     <project directory>\Setup.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message:
  Multi Cradle: No prefixes matched
  pwd: <project directory>
  filepath: <project directory>\Setup.hs
  prefixes:
  ("./src/Main.hs",Stack {component = Just "supercell:exe:supercell", stackYaml = Nothing})
2021-07-22 14:49:08.2302054 [ThreadId 41] INFO hls:     Consulting the cradle for "src\\Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "<project directory>", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `supercell' component supercell:exe:supercell with main-is file: <project directory>\src\Main.hs
> supercell> configure (exe)
> Configuring supercell-0.1.0.0...
> supercell> initial-build-steps (exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: supercell
> <project directory>\.stack-work\install\9059733e\pkgdb;C:\sr\snapshots\58c0b63b\pkgdb;C:\Users\bradn\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\package.conf.d
2021-07-22 14:49:32.5219814 [ThreadId 41] DEBUG hls:    Session loading result: Right (ComponentOptions {componentOptions = ["-i","-odir=<project directory>\\.stack-work\\odir","-hidir=<project directory>\\.stack-work\\odir","-hide-all-packages","-i<project directory>\\.stack-work\\dist\\274b403a\\build\\supercell","-i<project directory>\\src","-i<project directory>\\.stack-work\\dist\\274b403a\\build\\supercell\\autogen","-i<project directory>\\.stack-work\\dist\\274b403a\\build\\global-autogen","-i<project directory>\\.stack-work\\dist\\274b403a\\build\\supercell\\supercell-tmp","-stubdir=<project directory>\\.stack-work\\dist\\274b403a\\build","-IC:\\Users\\bradn\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20150512\\mingw64\\include","-LC:\\Users\\bradn\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20150512\\mingw64\\lib","-LC:\\Users\\bradn\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20150512\\mingw64\\bin","-package-id=base-4.14.1.0","-package-id=comonad-5.0.8-EA0Scey7jOW6LX5RvNTIb8","-package-id=containers-0.6.2.1","-package-id=data-fix-0.3.1-EEkJSvkKaVSJsOxIFinaX2","-package-id=deriving-compat-0.5.10-HXK3itbGHpR1pL3mr5zjAL","-package-id=free-5.1.7-4OirU2gKOjtHnqx24E6NNh","-package-id=megaparsec-9.0.1-LsaPGsu2KTg8EMdYsBX01R","-package-id=mtl-2.2.2","-package-id=parser-combinators-1.2.1-BgKMLJR8mPH8EvrPvvjrd8","-package-id=recursion-schemes-5.2.2.1-9EDXfZbCpz5BDq449BBurS","-package-id=threepenny-gui-0.9.1.0-8gce40SO3CV6JgGLJfIbm4","-Wall","-optP-include","-optP<project directory>\\.stack-work\\ghci\\db817aa6\\cabal_macros.h","-ghci-script=C:\\Users\\bradn\\AppData\\Local\\Temp\\haskell-stack-ghci\\ba68feb8\\ghci-script","-package-db","<project directory>\\.stack-work\\install\\9059733e\\pkgdb","-package-db","C:\\sr\\snapshots\\58c0b63b\\pkgdb","-package-db","C:\\Users\\bradn\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.10.4\\lib\\package.conf.d"], componentRoot = "<project directory>", componentDependencies = ["supercell.cabal","package.yaml","stack.yaml"]},"C:\\Users\\bradn\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.10.4\\lib")
2021-07-22 14:49:32.7637402 [ThreadId 41] INFO hls:     Using interface files cache dir: C:\Users\bradn\AppData\Local\ghcide\main-9ee7316b6da00c1f1bf3cacc9b939e1ebd8ca220
2021-07-22 14:49:32.7637402 [ThreadId 41] INFO hls:     Making new HscEnv[main]
2021-07-22 14:49:32.8106299 [ThreadId 41] DEBUG hls:    New Component Cache HscEnvEq: (([],Just HscEnvEq 5),fromList [("<project directory>\\hie.yaml",Just 2021-07-22 04:38:23.8434694 UTC),("package.yaml",Nothing),("stack.yaml",Just 2021-07-08 12:59:12.5066965 UTC),("supercell.cabal",Just 2021-07-18 02:48:07.1285272 UTC)])
2021-07-22 14:49:32.8106299 [ThreadId 41] DEBUG hls:    Known files updated: fromList [(TargetFile NormalizedFilePath "<project directory>\\src\\Main.hs",fromList ["<project directory>\\src\\Main.hs"])]
2021-07-22 14:49:32.8106299 [ThreadId 9] DEBUG hls:     Finishing build session(exception: AsyncCancelled)
2021-07-22 14:49:32.8106299 [ThreadId 41] DEBUG hls:    Restarting build session for keys [GhcSessionIO; ] (aborting the previous one took 0.00s)
2021-07-22 14:49:32.8106299 [ThreadId 90] DEBUG hls:    hlint:getIdeas:file:NormalizedFilePath "<project directory>\\src\\Main.hs"
2021-07-22 14:49:32.8106299 [ThreadId 99] INFO hls:     Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "<project directory>", cradleOptsProg = CradleAction: Stack}
2021-07-22 14:49:32.8106299 [ThreadId 99] DEBUG hls:    Session loading result: Left [CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Multi Cradle: No prefixes matched","pwd: <project directory>","filepath: <project directory>\\Setup.hs","prefixes:","(\"./src/Main.hs\",Stack {component = Just \"supercell:exe:supercell\", stackYaml = Nothing})"]}]
2021-07-22 14:49:35.2074858 [ThreadId 174] INFO hls:    finish: User TypeCheck (took 2.40s)
2021-07-22 14:49:35.2883541 [ThreadId 185] INFO hls:    finish: GetHie (took 0.07s)
Files that failed:
2021-07-22 14:49:35.2883541 [ThreadId 187] INFO hls:    finish: GenerateCore (took 0.00s)
 * <project directory>\Setup.hs

Completed (1 file worked, 1 file failed)
haskell-language-server-wrapper.exe: callProcess: C:\Users\bradn\Documents\Haskell\hls\haskell-language-server-8.10.4.exe "--debug" (exit 1): failed
@jneira jneira added component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. editor: emacs labels Jul 22, 2021
@jneira
Copy link
Member

jneira commented Jul 22, 2021

Thanks for your bug report. Could we got acess to the project to try to reproduce the problem? share it in github would be fine

@bradrn
Copy link
Contributor Author

bradrn commented Jul 22, 2021

@jneira I’d rather not share it just yet, but I’ll see if I can upload another project which shows this issue.

@bradrn
Copy link
Contributor Author

bradrn commented Jul 22, 2021

I have solved the mystery — this turned out to not be a bug at all! I was copying and pasting bits from my project Main.hs to my reproducer project, when I suddenly noticed the following line:

{-# OPTIONS_GHC -Wno-deferred-type-errors #-}

…which of course disabled all type errors in the module. Once I removed it, I suddenly started getting type errors again.

And I believe I know why this line got there in the first place. Whenever I get a warning, in the code actions HLS regularly allows me to disable that warning. Type errors are reported through -Wdeferred-type-errors, so this means that every time I get a type error, HLS ‘helpfully’ offers me an option to disable type errors, which I must have accidentally selected without realising:

image

I therefore suggest that, for this warning only, HLS should stop suggesting disabling -Wdeferred-type-errors, to avoid this problem happening again. (I’m sure I’m not the only one it’s happened to.)

@jneira
Copy link
Member

jneira commented Jul 22, 2021

Thanks, agree in is not a good idea suggest that, as you usually dont want to disable errors (ey, it is "if compile work" haskell 😉 )
The suggestion message is somewhat confusing, deferred-type-errors is being enabled by hls itself so it should not suggest remove it.

@jneira jneira added type: enhancement New feature or request and removed editor: emacs type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jul 22, 2021
@jneira jneira changed the title HLS does not report any type errors HLS suggest disable deferred-type-errors (needed for type error diagnostics) Jul 22, 2021
@jneira jneira changed the title HLS suggest disable deferred-type-errors (needed for type error diagnostics) HLS suggests disable deferred-type-errors (needed for type error diagnostics) Jul 22, 2021
@georgefst
Copy link
Collaborator

Yeah, I've been meaning to open an issue about this for a while, having initially added the functionality in #1235.

It should be easy enough to add a special case to that code, to ignore these warnings. Or if there are other warnings "enabled by hls itself", as @jneira says, then maybe we can do something more general.

@bradrn
Copy link
Contributor Author

bradrn commented Jul 31, 2021

@georgefst It would be nice to do something more general if there are any other warnings added by HLS, but if not I see no reason to not have a special case for -Wdeferred-type-errors.

anka-213 added a commit to anka-213/haskell-language-server that referenced this issue Aug 2, 2021
anka-213 added a commit to anka-213/haskell-language-server that referenced this issue Aug 2, 2021
@mergify mergify bot closed this as completed in #2061 Aug 2, 2021
mergify bot pushed a commit that referenced this issue Aug 2, 2021
* Add a failing test for #2032

* Don't suggest -Wno-deferred-type-errors

Fixes #2032
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants