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

Setting Language Disables Other Extensions #1604

Open
Burtannia opened this issue Jun 26, 2024 · 6 comments
Open

Setting Language Disables Other Extensions #1604

Burtannia opened this issue Jun 26, 2024 · 6 comments
Labels

Comments

@Burtannia
Copy link

While configuring my .hlint.yaml file for my Yesod project I ran into a strange issue. I decided to dump all my default-extensions as arguments into hlint just to ensure correct parsing. I'm using GHC2021 so I also wanted to pass -XGHC2021. The minimal example I can give is using template haskell:

- arguments: [
  --color,
  --cpp-simple,
  -XGHC2021,
  -XTemplateHaskell,
]

This should work just fine to my understanding, in fact -XTemplateHaskell is probably redundant because I believe hlint automatically enables it. Either way this produces warnings all over the place of the form:

src/Handler/Profile.hs:12:10-31: Suggestion: Redundant bracket
Found:
  do setTitle . toHtml $ userIdent user <> "'s User page"
    $ (widgetFile "profile")
Perhaps:
  do setTitle . toHtml $ userIdent user <> "'s User page"
    $ widgetFile "profile"

Removing -XGHC2021 from the arguments list fixes the issue and the warnings no longer show. My guess is that selecting the language version ignores any other extensions. The issue is also present using -XHaskell2010.

As an aside to this, it would be nice if hlint could automatically detect and use the language version / default-extensions from package.yaml to avoid the need for these arguments entirely. This seems to happen via HLS in VSCode but does not happen when running hlint manually via the command line.

@LiamGoodacre
Copy link

Just ran into this too, specifically with GHC2021 & TemplateHaskell; (hlint 3.6.1)

@shayne-fletcher
Copy link
Collaborator

shayne-fletcher commented Oct 31, 2024

if you pass nothing, hlint will decide for itself what extensions to enable based on the principle of being able to parse as broad a set of haskell as possible.

if you pass -XGHC2021 then that defines the set of extensions that are enabled and nothing more. to get the GHC2021 extensions and TemplateHaskell then -XGHC201 -XTemplateHaskell should do it

(i should point out, this is the behavior on the command line i'm talking about - i haven't looked at what happens with arguments passed in .hlint.yaml files before - maybe there's an issue with that?)

@LiamGoodacre
Copy link

to get the GHC2021 extensions and TemplateHaskell then -XGHC201 -XTemplateHaskell should do it

This doesn't appear to work (3.6.1) neither as command line arguments nor arguments in the yaml file.

Example.hs

module Example where

example = $(something)

With command args

∀ hlint -XGHC2021 -XTemplateHaskell Example.hs
Example.hs:3:11: Error: Parse error: on input `$'
Found:
    module Example where

  > example = $(something)


1 error

With config file

example.hlint.yaml

- arguments:
    - -XGHC2021
    - -XTemplateHaskell
∀ hlint --hint=example.hlint.yaml Example.hs
Example.hs:3:11: Error: Parse error: on input `$'
Found:
    module Example where

  > example = $(something)


1 error

Only TemplateHaskell (no GHC2021)

∀ hlint -XTemplateHaskell Example.hs
No hints

@shayne-fletcher
Copy link
Collaborator

quick test here with v3.8 on the command line seems to confirm the reported issue

@shayne-fletcher
Copy link
Collaborator

i still haven't quite worked out what is up with this but i have a workaround: hlint -XGHC2021 -XTemplateHaskell -XTemplateHaskellQuotes ...

@shayne-fletcher
Copy link
Collaborator

i put a fix up for this in #1619. bit surprised, i knew that we'd looked at extensionImplications before but i couldn't find anywhere we went and used it!

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

No branches or pull requests

3 participants