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

Code action to add existing, unused pragma #1390

Open
alanz opened this issue Feb 17, 2021 · 5 comments
Open

Code action to add existing, unused pragma #1390

alanz opened this issue Feb 17, 2021 · 5 comments
Labels
component: hls-pragmas-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@alanz
Copy link
Collaborator

alanz commented Feb 17, 2021

I have a file with pragmas at the top

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExplicitNamespaces #-}

DeriveAnyClass is unused, and hlint reports this. But I get a code action to add it.

Screenshot 2021-02-17 at 15 08 16

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.9.0.0 (GHC: 8.8.4) (PATH: /Users/alanzimm/.cabal/store/ghc-8.8.4/hskll-lngg-srvr-0.9.0.0-a8c1156a/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		2.5.1
ghc:		8.8.4

Which lsp-client do you use: emacs lsp-mode

HLS at a065cd6

@berberman
Copy link
Collaborator

This is a known bug: #1165 (comment)

@berberman berberman added component: plugins status: blocked Not actionable, because blocked by upstream/GHC etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Feb 17, 2021
@Anton-Latukha
Copy link
Collaborator

If blocked upstream - what is the upstream report link?

@jneira
Copy link
Member

jneira commented Dec 25, 2021

the linked #1165 is from this repo, maybe it was moved from ghcide?

@jneira jneira removed the status: blocked Not actionable, because blocked by upstream/GHC etc. label Dec 25, 2021
@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Dec 25, 2021

Link probably should be: https://gitlab.haskell.org/ghc/ghc/-/issues/18516, but I need to ask people in the thread to be sure.

@jneira
Copy link
Member

jneira commented Dec 25, 2021

Oh yeah, structured errors in ghc will help a lot to fix this (and other issues for sure), as described in the linked comment in the merged pr.
We have an issue in the repo from the actual implementors of that ghc feature: #2014


The relevant comment in the pr is:

  • Ideally, we'd have errors-as-values proposal ghc-proposals/ghc-proposals#306 so that we'd only have to search for pragma names in the right field(s?) of the structured GHC error, instead of having to search the entire error message. Even better, the structured GHC error could contain a field with suggested pragmas 🙂.

  • In the meantime, there is another alternative: instead of matching just the pragma names, which might trigger false positives, we could use some regexps like below (copied from my Emacs config):

 (or (and " -X\\([A-Z][A-Za-z]+\\)"
          (not "\\([A-Z][A-Za-z]+\\) is deprecated"))
     "[Uu]se \\([A-Z][A-Za-z]+\\)"
     "Using \\([A-Z][A-Za-z]+\\) might"
     "You need \\([A-Z][A-Za-z]+\\)"
     "Try \\(?:enabling \\)?\\([A-Z][A-Za-z]+\\)"
     "intended to use \\([A-Z][A-Za-z]+\\)"
     "Enable \\(?:the \\)?\\([A-Z][A-Za-z]+\\)"
     "need \\([A-Z][A-Za-z]+\\) turned on"
     "extension '\\([A-Z][A-Za-z]+\\)'")

(I'm sure the regexp can be optimised, it's just something that grew organically.) However, this is rather ad-hoc and will get out of date when an error message is added/changed in GHC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-pragmas-plugin 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

4 participants