
#8044: "Inaccessible code" error reported in wrong place --------------------------------------------+------------------------------ Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.7 Resolution: | Keywords: GADTs Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by goldfire): Ah, but {{{Frob}}} is a hot-off-the-presses ''closed type family'', which allows such things. The idea is that the equations match top-to-bottom, much like term-level functions. Because the reasoning is static (at compile-time), we have to be more careful about this top-to-bottom matching, refusing to let `Frob q` reduce to `Char` before we know that `q` cannot possibly become `Int`. This is why the code in the example above is erroneous. Despite the previous case checking for `XInt`, GHC does not know when type-checking the second equation for `frob` that the type variable `a` cannot be `Int`. Thus, it cannot simplify `Frob a` and it cannot accept `XChar` as well-typed. So, the bug I'm reporting is not that GHC rejects my program. It should indeed reject that program. The problem is that the error message points out the wrong (as in, non-existent) error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8044#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler