ghcid icon indicating copy to clipboard operation
ghcid copied to clipboard

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

Open jumper149 opened this issue 2 years ago • 4 comments

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:

  • Just checked my ghcid version: Auto reloading GHCi daemon v0.8.7
  • I am using nixpkgs pinned to e9545762b032559c27d8ec9141ed63ceca1aa1ac
  • Using the regular haskellPackages, which uses GHC 8.10.7

jumper149 avatar Mar 17 '22 16:03 jumper149

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 avatar Mar 18 '22 13:03 jumper149

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.

jumper149 avatar Mar 18 '22 13:03 jumper149

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.

ndmitchell avatar Mar 26 '22 11:03 ndmitchell

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. :)

theophile-scrive avatar Jan 16 '23 12:01 theophile-scrive