Subject: mkIfaceTc panics with "lookupVers1"
From: "Erdi, Gergo" <[email-masked]>
To: 'GHC' <[email-masked]>
Cc: "Montelatici, Raphael Laurent" <[email-masked]>
Date: Tue, 13 Jul 2021 08:02:09 +0000

PUBLIC

Hi,

I'm trying to use `mkIfaceTc` to make a ModIface from the results of typechecking. Everything goes well until it gets to `makeFullIface`, where it fails to find some imported fingerprints:

hello: hello: panic! (the 'impossible' happened)

  (GHC version 9.0.1:

        lookupVers1

MyPrim Foo

Call stack:

    CallStack (from HasCallStack):

      callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc-lib-9.0.1.20210623-3xx7a2u7IkN9vKAnkscROb:GHC.Utils.Outputable

      pprPanic, called at compiler/GHC/Iface/Recomp.hs:1455:19 in ghc-lib-9.0.1.20210623-3xx7a2u7IkN9vKAnkscROb:GHC.Iface.Recomp

I am using the GHC API to load my modules differently than what GHC itself does; I am attaching the full code, but perhaps to note is that I am creating ModSummarys one by one and then typechecking and adding them to the moduleNameProviderMap in dependency order. Also, I am using `downsweep` directly instead of `depanal`, because the latter's `flushFinderCaches` was breaking my inter-unit imports.

Because the attached code is a minimized version of something larger, some parts of it may seem to be doing things in a roundabout way but that's because in the real program all those degrees of freedom are used. In case that matters, the only packages in my package DB are  rts, ghc-prim-0.7.0 and ghc-bignum-1.0.

So my question is basically, what am I doing wrong? Why is fingerprinting failing on `Top.hs`'s import of `MyPrim.hs`, and how do I fix that, while still keeping this total control over when and how modules are typechecked and loaded?

Thanks,

            Gergo