[GHC] #11824: GHC error in desugarer lookup

Ben Gamari ben at well-typed.com
Wed Apr 13 13:53:01 UTC 2016

Simon Peyton Jones <simonpj at microsoft.com> writes:

> Ben
> I'm offline, so can't reply on Phab.
> Calling mkTypeableBinds in tcRnHsBootDecls isn't quite right, because it'll generate lots of *bindings* whereas all we want is the *Ids* in the GlobalValEnv.
> (It's possible that tcg_binds is ignored in the boot-module case, but it's unsavoury to generate the bindings at all.  They are generated when we process the main module.)
> I suggest the easiest fix is, in mkModIdBinding and mkTypeableTyConBinds, guard the binding-generation with a test for whether isHsBootOrSig is true.
Are you concerned about the bindings being generated at all or merely
that they are being added to the typechecking environment?

If the latter there is no reason to fear: TcBinds.addTypecheckedBinds
(which TcTypeable uses) ensures that no bindings are added to the
environment if we are compiling a boot module,

    addTypecheckedBinds :: TcGblEnv -> [LHsBinds Id] -> TcGblEnv
    addTypecheckedBinds tcg_env binds
      | isHsBootOrSig (tcg_src tcg_env) = tcg_env
        -- Do not add the code for record-selector bindings
        -- when compiling hs-boot files
      | otherwise = tcg_env { tcg_binds = foldr unionBags
                                                (tcg_binds tcg_env)
                                                binds }

Of course, we are still doing the work of producing the bindings; if it
is this that you are concerned about then I can be more careful in
guarding their production.


- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160413/9443163b/attachment.sig>

More information about the ghc-devs mailing list