jyp / dante

389 stars 52 forks source link

Errors are reported in temp file #137

Closed bradrn closed 4 years ago

bradrn commented 4 years ago

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 use flycheck-next-error and flycheck-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.

bradrn commented 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.

bradrn commented 4 years ago

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: