ndmitchell / hlint

Haskell source code suggestions
Other
1.45k stars 194 forks source link

Setting Language Disables Other Extensions #1604

Open Burtannia opened 1 week ago

Burtannia commented 1 week ago

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.