ghc 8.8.x change in behaviour when loading in-memory modules

Tseen She ts33n.sh3 at
Wed Feb 26 20:53:05 UTC 2020

Dear ghc devs,

I am in the process of updating my dev tool, which uses the ghc api, to
support ghc-8.8.x.

However, I have noticed that one of my regression tests is failing, and I
have isolated the problem to a change in behaviour in typecheckModule when
using a Target with an in-memory buffer (i.e. targetContents is a Just).

Using debug tracing, I can confirm that in the following code, the
ms_hspp_buf of a ModSummary has my in-memory version:

  minf_rdr_env' :: GHC.GhcMonad m => GHC.ModuleName -> m GlobalRdrEnv
  minf_rdr_env' m = do
    modSum <- GHC.getModSummary m
    pmod <- GHC.parseModule modSum
    tmod <- GHC.typecheckModule pmod
    let (tc_gbl_env, _) = GHC.tm_internals_ tmod
    pure $ tcg_rdr_env tc_gbl_env

You can see how I setup the session in

And whereas in 8.4.4 and 8.6.5 the typecheckModule call is working on the
in-memory representation, in 8.8.1 and 8.8.2 it is falling back to the
version on disk and therefore failing, because I have made in-memory
changes that are necessary.

Aside: I am able to observe this because I have a function that trims
everything except the module declaration and import section, and can
therefore tolerate typos in the rest of the file. Now my code fails if the
entire file does not typecheck, which is also incredibly slow, because I
only want access to the import section.

Best regards,
Tseen She
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list