[GHC] #9729: GHCi accepts invalid programs when recompiling

GHC ghc-devs at haskell.org
Fri Oct 31 13:36:00 UTC 2014


#9729: GHCi accepts invalid programs when recompiling
-------------------------------------+-------------------------------------
              Reporter:  crockeea    |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  GHCi        |          Version:  7.8.3
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:  GHC         |       Blocked By:
  accepts invalid program            |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 The problem is this.

  * When compiling A we load up the interface file for
 `Data.Syntactic.Sugar.BindingT`, since A imports it.  It includes an
 orphan instance declaration for the type family `Internal`.

  * That populates the `eps_fam_inst_env`, globally across all packages,
 recording an instance for the type family `Internal`.

  * Then when recompiling B we see the instance.

 The solution, I think, is this:

  * During instance lookup, for type families or classes, if the matched
 instance is an orphan, then check that the host module for the instance is
 transitively below the module being compiled.

 We only need to do this check for orphan instance, because it's guaranteed
 true for non-orphans.

 GHC already keeps a list of all the orphan modules transitively below the
 one being compiled, in the `imp_orphs` field of `tcg_imports`.  So the
 check should be easy to do.  That said, a `ModuleSet` would be better than
 a list, for fast membership checks.

 Edward is already working on adding more info to the `imp_orphs` field:
 see Trac #9717.  It might be better to combine the two.

 Edward would you like to comment?

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9729#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list