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

Module import code action ignores reexported-modules #2554

Closed
guibou opened this issue Dec 30, 2021 · 4 comments
Closed

Module import code action ignores reexported-modules #2554

guibou opened this issue Dec 30, 2021 · 4 comments
Labels
component: imports plugin status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@guibou
Copy link
Collaborator

guibou commented Dec 30, 2021

Your environment

Which OS do you use: Linux
Which LSP client (editor/plugin) do you use: NeoVim + lspconfig
Describe your project (alternative: link to the project): https://github.com/guibou/repro_hls_base_no_prelude

Steps to reproduce

You can checkout https://github.com/guibou/repro_hls_base_no_prelude, it contains two cabal project with one Main.hs file with the following content:

{-# LANGUAGE NoImplicitPrelude #-}
module Main where

main :: IO ()
main = putStrLn "Hello, Haskell!"

Expected behaviour

The code above should not typecheck (i.e. IO is not in scope). Code action on the offending line should suggestion to import a few module, such as System.IO or Prelude.

Actual behaviour

There is two variations in the sample codebase.

  • One is a project with base as a dependency. Code action works as expected and suggest to import System.IO (as well as other modules from base which exports IO).

image

image

Note that in both cases, importing System.IO fixs the type error.

@guibou guibou added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Dec 30, 2021
@jhrcek
Copy link
Collaborator

jhrcek commented Dec 30, 2021

Could you please share the precise version of haskell-language-server you're using?
I was experiencing similar issue (we're also using base-noprelude) and I think I fixed the problem in #2468
If it doesn't help with your issue, that fix might need to be revisited.

Here's what the code action offers to me in your reproducer project (haskell-language-server built from current master):

Screenshot from 2021-12-30 18-37-14

@jneira jneira added component: imports plugin status: needs info Not actionable, because there's missing information and removed status: needs triage labels Dec 30, 2021
@guibou
Copy link
Collaborator Author

guibou commented Dec 31, 2021

That's a super question that I should have answered when opening the issue.

  • In my repro example, I use 1.5.1.0 as available in nixpkgs, so I suppose that's 1.5.1.0
  • In my main repo, I use 87a69c2

Both are actually older than your #2468 so hey, the fix may already be there.

I'll try when next version will be released, the nix flake for current dev version does not work anymore (see #2030).

Thank you for your time.

@guibou guibou closed this as completed Dec 31, 2021
@guibou
Copy link
Collaborator Author

guibou commented Jan 1, 2022

@jhrcek I was able to test with latest HLS (master) and indeed the bug is fixed.

Thank you for your work, sorry for the noise, have a nice year!

@jhrcek
Copy link
Collaborator

jhrcek commented Jan 1, 2022

@guibou thank you for confirming, my pleasure that the fix is useful for others.
Happy new year to you too 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: imports plugin status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants