[GHC] #13981: Family instance consistency checks happens too early when hs-boot defined type occurs on LHS
GHC
ghc-devs at haskell.org
Mon Jul 17 14:03:47 UTC 2017
#13981: Family instance consistency checks happens too early when hs-boot defined
type occurs on LHS
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.2.1-rc2
checker) |
Resolution: | Keywords: hs-boot
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 ezyang):
Yeah. The details are in `Note [Don't check hs-boot type family instances
too early]`, but reproduced below:
* So, the origin of a panic "tcIfaceGlobal (local): not found" is when
force the TyThing of a locally defined type prior to having actually
typechecked that type. Ordinarily this can't happen (since you can't even
get your hands on the TyThing before you've typechecked the type), but
when you have an hs-boot file, a placeholder thunk for the TyThing is put
into the context, and the onus is on you to avoid forcing this thunk until
it is ready.
* Type family consistency checking happens prior to any typechecking, and
(as first discovered in #11062) it can cause a TyThing of an hs-boot
defined type family to be forced too early. Originally, I suggested that
we simply do the consistency check after all typechecking was done. But
this has its own problem: if we do the consistency check too late, we may
end up typechecking Haskell code under inconsistent/overlapping sets of
axioms, which could lead to very strange errors.
* Thus, we have to defer some of the consistency checks. We first do all
of the consistency checks that could not possibly force a TyThing
immediately, and then as we finish kind-checking a type family, we then go
ahead and do all of the deferred consistency checks involving that family.
* What I didn't realize when I originally wrote this patch is that the
early forcing isn't limited just to a type family: types which occur in
the LHS of overlapping instances (`T` above) also have this problem. So
some new solution needs to be found.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13981#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list