Closed bradrn closed 4 years ago
Dante seems to be working now — I opened Emacs, and all of the errors were reported correctly. I’m not sure why it’s working though: I haven’t made any changes to my config since I reported this issue, and can’t think of any explanation (unless restarting Emacs was all that was needed to fix this). Due to this, I think I’ll keep this issue open until I figure out the explanation, in case this issue recurs for anyone else.
EDIT: I spoke too soon — the issue is back again. Again, without doing anything obvious.
I finally figured out the cause of this bug! It’s from this bit of code:
https://github.com/jyp/dante/blob/9289b6f053f343cb841ea7ca74758fe41bf6b74c/dante.el#L358-L360
There are three variables involved here: temp-file
is the location of Dante’s temporary file, file
is the file reported in GHC’s error message, and buffer
is the buffer which is being edited. If temp-file
and file
are equal, then the location of the error is given as being buffer
; otherwise, the location is given as file
.
The issue turns out to be that, on Windows, temp-file
is given with forward slashes and a lowercase drive letter, but file
is given with backslashes and an uppercase drive letter. Thus, even though they point to the same temporary file in the vast majority of cases, they can never be equal and the error is always reported as being in file
, i.e. the temporary file, rather than buffer
, where the error should be reported.
I see two solutions:
(dante-buffer-file-name buffer)
. This works — and is the workaround I am currently using — but breaks the ‘other file’ feature added in https://github.com/jyp/dante/commit/b0ca87b73fe52430085fe1a6b7b22e256c329388.dante-canonicalize-path
, but this function does not take slashes into account yet. A full solution would replace (string= temp-file file)
with (string= (dante-canonicalize-path temp-file) (dante-canonicalize-path file))
, as well as change dante-canonicalize-path
to take slashes into account (although I’m not too sure how to do that last bit). EDIT: This can actually be done pretty easily with (replace-regexp-in-string "/" "\\" path t t)
(from https://stackoverflow.com/a/1037749/7345298). I’ll send in a PR when I get some time.
I’ve just started using Dante, and noticed that errors are reported in a temporary file (for me,
dante1yDe13.hs
) instead of the actual file I’m editing. This is a problem, since I useflycheck-next-error
andflycheck-previous-error
to move between errors, and this issue causes me to move to the temporary file instead of the file I’m editing. This is despite https://github.com/jyp/dante/issues/78#issuecomment-413336831, which states that ‘dante no longer creates temp files’.EDIT: I should probably mention as well that this issue means that errors don’t get highlighted in the buffer. The highlights end up in the temporary file instead.