[GHC] #13102: orphan family instances can leak through the EPS in --make mode

GHC ghc-devs at haskell.org
Wed Jan 11 10:47:44 UTC 2017


#13102: orphan family instances can leak through the EPS in --make mode
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 Replying to [comment:3 simonpj]:
 > Aha!  You are right!  The relevant ticket is #2182. One thing unsaid
 there is that non-orphan instances cannot be a problem because the module
 defining a non-orphan instance must be in the transitive closure of
 modules below the one being compiled.  It's just orphan modules that we
 need to take care about.

 So the logic here is: a non-orphan (class or type family) instance is one
 which is either an instance of a class/family defined in the same module
 or an instance that mentions a type constructor defined in the same
 module. Either way, in order to use the instance both the class/family and
 the type constructor must be in scope, so we must have actually imported
 them (rather than obtained them through leakage from compiling another
 module).

 The last step is not entirely true since the type constructor might also
 be in scope by virtue of being a wired-in type that corresponds to Haskell
 syntax, like a tuple. Then I don't actually have to import anything to be
 able to write the type. If the module `W` defining a wired-in thing
 defines an instance of a class defined in another module for that thing, a
 user program could see the instance without having to import `W`. I don't
 know whether this currently occurs in base (it seems to at least not
 happen for type families), but it's what I wanted to add in #13072.

 Not saying this should block adoption of the cunning plan, just that it is
 another wrinkle to be aware of.

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


More information about the ghc-tickets mailing list