ghcid icon indicating copy to clipboard operation
ghcid copied to clipboard

Language.Haskell.Ghcid `showModules` incorrectly parses context information as module names (GHCi 9.4.4)

Open CrystalSplitter opened this issue 1 year ago • 0 comments

showModules in the Ghcid library is mostly just a parsing wrapper around exec :show modules. However, in certain execution contexts, it returns the execution location information as a module in the given listing, e.g.:

Example from some shellcheck debugging (recovered from logs):

>>> Ghcid.exec ghci ":show modules"
["()","[shellcheck.hs:204:5-21] #~GHCID-START~#()","[shellcheck.hs:204:5-21] #~GHCID-START~#Main             ( shellcheck.hs, interpreted )"]
>>> Ghcid.showModules ghci
[("[shellcheck.hs:204:5-21]","shellcheck.hs")]
-- Should be [("Main", "shellcheck.hs")]

There's a number of cases where #~GHCID-START~# seems to not be properly filtered out during execution. In my use case, this is very common, and easily worked around. However, showModules blindly parses this incorrectly.

The start up command for ghcid above was cabal v2-repl --repl-options'-fno-it', though this also happens with cabal v2-repl regardless.

CrystalSplitter avatar Oct 02 '23 04:10 CrystalSplitter