haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Hlint parser error on `pattern` #1374

Open fendor opened 5 years ago

fendor commented 5 years ago

Given a module:

module Lib where

foo pattern = pattern

This error message is shown:

/tmp/ghc-mod4106/Lib4105-43.hs:3:5: error:
    parse error on input `pattern'
  module Lib where

> foo pattern = pattern

This is documented in https://github.com/ndmitchell/hlint/issues/607. Minimal project to reproduce: https://github.com/fendor/hlint-minimal-pattern

This happens because hlint assumes some default extensions. This makes sense, since hlint is normally not aware of a .cabal or package.yaml file, where extensions may be listed. However, HIE is aware of language extensions and could invoke hlint always with the right extensions.

alexshadley commented 5 years ago

This project looks exciting, I'd love to start contributing! I can take a stab at this issue and let everyone know how it goes.

fendor commented 5 years ago

I think that https://github.com/haskell/haskell-ide-engine/blob/master/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs#L142 is responsible. I am not sure what the best way is to tackle the problem, e.g. I dont think the enabled Language Extensions are known in that function, so, that might be tricky. It is probably sensible to add a test to https://github.com/haskell/haskell-ide-engine/blob/master/test/unit/ApplyRefactPluginSpec.hs that reproduces the problem.