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 ignores GHC plugins #3299

Closed
JakobBruenker opened this issue Oct 22, 2022 · 3 comments · Fixed by #3309
Closed

HLS ignores GHC plugins #3299

JakobBruenker opened this issue Oct 22, 2022 · 3 comments · Fixed by #3309
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@JakobBruenker
Copy link
Contributor

JakobBruenker commented Oct 22, 2022

Your environment

Ubuntu (under Windows 11 WSL)
ghc 9.4.2 via ghcup

Reproduction repo with minimal example:
https://github.com/JakobBruenker/plugin-test

Which LSP client (editor/plugin) do you use?
VS Code, but running haskell-language-server outside of it produces the same error

Which version of HLS do you use and how did you install it?
1.8.0.0 via ghcup

Have you configured HLS in any way (especially: a hie.yaml file)?
No (though an hie.yaml file generated via implicit-hie seemed to make no difference)

Steps to reproduce

Clone the reproduction repo linked above and run haskell-language-server inside just-some-project.

NB: Because of #3297, this does not work if you run HLS in the top-level directory plugin-test.

Expected behaviour

There should be no errors, since the plugin replaces puStrLn with putStrLn.

Actual behaviour

HSL shows the error

  Variable not in scope: puStrLn :: String -> IO ()
  Suggested fix: Perhaps use ‘putStrLn’ (imported from Prelude)

Even though the plugin changes the name to putStrLn, which means cabal run works just fine.

Strangely, I seem to remember doing something similar 6 months ago and it worked, but now I can't get it to work with 9.2 either, but it may have been a different kind of plugin.

@JakobBruenker JakobBruenker added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Oct 22, 2022
@michaelpj
Copy link
Collaborator

I think source plugins don't work, see e.g. #2779

I don't think anyone particularly knows why though. It probably needs a plugin champion!

@JakobBruenker
Copy link
Contributor Author

JakobBruenker commented Oct 26, 2022

Ah, I suppose this is a duplicate ticket then and can be closed? (Edit: Maybe not though, since the error is quite different)

I'm writing a plugin at the moment and am definitely considering fixing this after I'm done, so the plugin will actually be useful. Not sure yet if I'll be able to figure how out, though.

@fendor
Copy link
Collaborator

fendor commented Oct 29, 2022

Issue is likely caused by us invoking the GHC API incorrectly 🙃 https://github.com/haskell/haskell-language-server/blob/master/ghcide/src/Development/IDE/Core/Compile.hs#L572

Since GHC 9.0, Plugins have moved to HscEnv from DynFlags, but we don't modify the HscEnv correctly, it seems to be a mistake from #2128

JakobBruenker added a commit to JakobBruenker/haskell-language-server that referenced this issue Oct 30, 2022
Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags.
This caused HLS not to run source plugins anymore. This commit fixes
that.

Fixes haskell#3299 and haskell#2779.
JakobBruenker added a commit to JakobBruenker/haskell-language-server that referenced this issue Oct 30, 2022
Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags.
This caused HLS not to run source plugins anymore. This commit fixes
that.

Fixes haskell#3299 and haskell#2779.
JakobBruenker added a commit to JakobBruenker/haskell-language-server that referenced this issue Oct 31, 2022
Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags.
This caused HLS not to run source plugins anymore. This commit fixes
that.

Fixes haskell#3299.
wz1000 pushed a commit that referenced this issue Dec 20, 2022
Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags.
This caused HLS not to run source plugins anymore. This commit fixes
that.

Fixes #3299.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants