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

Tseen She ts33n.sh3 at gmail.com
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:


https://gitlab.com/tseenshe/hsinspect/-/blob/dfcb50a4e3437fbb4d0a3eb786b99c3a527d5e23/library/HsInspect/Workarounds.hs#L77-84

  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


https://gitlab.com/tseenshe/hsinspect/-/blob/dfcb50a4e3437fbb4d0a3eb786b99c3a527d5e23/library/HsInspect/Imports.hs#L21-35

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: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20200226/e471da0f/attachment.html>


More information about the ghc-devs mailing list