• Simon Peyton Jones's avatar
    Fix treatment of hi-boot files and dfuns · a57d5c4d
    Simon Peyton Jones authored
    Trac #16038 exposed the fact that TcRnDriver.checkHiBootIface
    was creating a binding, in the module being compiled, for
       $fxBlah = $fBlah
    
     but $fxBlah was a /GlobalId/. But all bindings should be for
     /LocalIds/ else dependency analysis goes down the tubes.
    
    * I added a CoreLint check that an occurrence of a GlobalId
      is not bound by an binding of a LocalId.  (There is already
      a binding-site check that no binding binds a GlobalId.)
    
    * I refactored (and actually signficantly simplified) the
      tricky code for dfuns in checkHiBootIface to ensure that
      we get LocalIds for those boot-dfuns.
    
    Alas, I then got "duplicate instance" messages when compiling
    HsExpr. It turns out that this is a long-standing, but extremely
    delicate, bug: even before this patch, if you compile HsExpr
    with -ddump-tc-trace, you get "duplicate instance". Without
    -ddump-tc-trace, it's OK.  What a mess!
    
    The reason for the duplicate-instance is now explained in
    Note [Loading your own hi-boot file] in LoadIface.  I fixed
    it by a Gross Hack in LoadIface.loadInterface. This is at
    least no worse than before.
    
    But there should be a better way. I have opened #16081 for this.
    a57d5c4d
TcRnDriver.hs 120 KB