
#15116: GHC internal error when GADT return type mentions its own constructor name -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: GADTs, Resolution: | TypeInType Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Written before Simon's "I'm on this", but I thought it worthy of posting anyway: I like: 3. Add the right `APromotionErr` entries into the env't for `tcConDecl`. `kcTyClGroup` calls `getInitialKinds`, which returns a `NameEnv TcTyThing`, mapping names to `TcTyThing`s. Note how `TcTyThing` includes the `APromotionErr` constructor (see its definition in `TcRnTypes`). ``getInitialKinds` not only maps tycon names to `TcTyCon`s (stored in `ATcTyCon`) but it also maps datacons to `APromotionErr`s. This is done in `getInitialKinds`'s call to `mkPromotionErrorEnv`. So, when we look up a datacon in `kcTyClDecl`, we get a `APromotionErr`, just as we should. Compare to the env't in place for `tcTyClDecls`, which is built with `zipRecTyClss`. This env't does ''not'' have the `APromotionErr`s. (See comment above the call to `zipRecTyClss`.) The solution is to extend the env't used in type checking to have the `APromotionErr` entries -- but only for the datacons, not for the tycons (which are no longer errors!). So you'd This is gnarly code, but this aspect of it isn't as complicated as others. It would make for a good exercise for someone (cough cough) who is working toward becoming an Official Type Checker Grease Monkey. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15116#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler