Open veniversum opened 8 years ago
I'm experiencing the same thing. Did you ever find a fix?
Usually this happens when the filenames don't match IIRC. Might that be the case?
When you say filenames don't match, do you mean file name and module name?
I tried ghc-mod
in a file called Temp.hs
, but I started the file with module Main where
because it is meant to be an executable.
Here is what I put in /tmp/Test.hs
:
module Main where
import Data.Ma -- Error here
main :: IO ()
main = putStrLn "hello"
Here is what ghc-mod check
reports on the command line:
tmp $ ghc-mod check Test.hs
Test.hs:3:8:Could not find module ‘Data.Ma’Perhaps you meant Data.Map (from containers-0.5.6.2
@conta_LKCPrTJwOTOLk4OU37YmeN) Data.Eq (from base-4.8.1.0) Data.Ix (from base-4.8.1.0)Use -v
to see a list of the files searched for.
However, the red squiggly line is in the top left.
You'll want to start looking somewhere around here: https://github.com/kazu-yamamoto/ghc-mod/blob/master/elisp/ghc-check.el#L156
That's where the overlays are constructed. If you trace through that you should be able to figure out why (file-equal-p ofile file)
doesn't hold, which is what I meant by "file names don't match". IIRC that's the bit that decides whether the info is for the current buffer's file or another one, in which case we highlight the first line in the buffer instead.
You can use C-h C-f
to jump to the definition of ghc-check-highlight-original-buffer
inside Emacs. Using C-u C-M-x
while point is in that source file will instrument the function using EDebug which will then break on the next entry and allow you to step through the evaluation with SPC
(while displaying the current value in the minibuffer). You can use q
to exit EDebug and just C-M-x
to re-evaluate the function without instrumentation, also while point is in the function's body.
Yup: if (buffer-live-p buf)
is nil.
(defmacro ghc-with-current-buffer (buf &rest body)
;; (declare (indent 1))
`(if (buffer-live-p ,buf)
(with-current-buffer ,buf
,@body)))
This issue seems to have been fixed.
When checking with hlint in emacs, the first line of the file is highlighted/underlined as a warning or error instead of the actual place for the suggestion.
Running
ghc-mod lint filename.hs
in console correctly generates list of suggestions with line numbers and positions, e.g.but only the first line of the file is underlined in emacs and the warning shown while hovered over.
emacs version: 25.0.50.1 ghc-mod version: 5.4.0.0 hlint version: 1.9.21