haskell / haskell-ide-engine

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

When Errors are present goto goes to a empty temporary file #1286

Closed Avi-D-coder closed 5 years ago

Avi-D-coder commented 5 years ago

If an error is present in app/Main.hs any goto on definition in the same file) will send me to empty file like /tmp/ghc-mod15112/Main15110-415110-22.hs

I'm using an update hie with https://github.com/alanz/ghc-mod/pull/20.

fendor commented 5 years ago

Does this happen only on this branch? Or did you only notice it on this branch? Because, iirc, there is an issue about that somewhere. Also, is there something to reproduce it?

Avi-D-coder commented 5 years ago

I noticed it on this branch, I have not had time to reproduce it on master.

Avi-D-coder commented 5 years ago

The issue exists on master

wz1000 commented 5 years ago

This occurs when we have a parsed module, but not a typechecked module, and is due to the update of reverse file map/rfm at https://github.com/haskell/haskell-ide-engine/blob/0b2cdf504303e510cdea8153352a6f4ab9c67a5b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs#L228

We update the reverse file mapping according to the state of the mapped files when the parsed module is generated. However, the old typechecked module that is retained still contains SrcSpans generated according to the previous state of the mapped files. So, when we use information from the typechecked module to answer queries, we are not able to map the temporary file to the real file.

Hopefully this class of issues will be solved once and forall in GHC 8.8+ by @DanielG fixing GHCs support for memory mapped files. Until then, I am pushing a fix.