ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.13k stars 114 forks source link

Handle `-Wprepositive-qualified-syntax` and `-Wmissing-local-signatures` #358

Open jumper149 opened 2 years ago

jumper149 commented 2 years ago

When -Wprepositive-qualified-syntax is enabled, an artifact remains after reloading finishes:

<interactive>:1:8-16: warning: [-Wprepositive-qualified-module]
    Found ‘qualified’ in prepositive position
    Suggested fix: place  ‘qualified’ after the module name instead.

Note, that cabal build doesn't throw this warning. I guess this comes from the initialization of ghcid, but I'm no expert here. ^^

Edit:

jumper149 commented 2 years ago

I just noticed, that the same thing happens for -Wmissing-local-signatures:

<interactive>:1:1: warning: [-Wmissing-local-signatures]
    Polymorphic local binding with no type signature:
      _compileParsedExpr :: forall a.
                            ghc-prim-0.6.1:GHC.Types.IO a -> ghc-prim-0.6.1:GHC.Types.IO a
<interactive>:1:8-16: warning: [-Wprepositive-qualified-module]
    Found ‘qualified’ in prepositive position
    Suggested fix: place  ‘qualified’ after the module name instead.
jumper149 commented 2 years ago

Also, this might be of interest:

-Wmissing-local-signatures is also thrown by cabal repl:

<interactive>:1:1: warning: [-Wmissing-local-signatures]
    Polymorphic local binding with no type signature:
      _compileParsedExpr :: forall a.
                            ghc-prim-0.6.1:GHC.Types.IO a -> ghc-prim-0.6.1:GHC.Types.IO a

-Wprepositive-qualified-module is NOT thrown by cabal repl.

ndmitchell commented 2 years ago

The solution is probably to add to https://github.com/ndmitchell/ghcid/blob/master/src/Language/Haskell/Ghcid/Parser.hs#L60, so these are understood and the scope of the warning can be determined. Ghcid doesn't really know if things come from the underlying ghci or cabal, so the same parser handles both.

theophile-scrive commented 1 year ago

I believe this is going to become a more widespread issue as more codebases enter GHC2021. @ndmitchell If you know the path to resolution it could be interesting to send out a call for contribution on this specific issue. :)