[GHC] #10195: GHC forgets constraints when matching on GADTs

GHC ghc-devs at haskell.org
Fri Mar 27 05:00:54 UTC 2015


#10195: GHC forgets constraints when matching on GADTs
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.8.4
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 I'm no expert on this part of the compiler, but it looks like GHC reduces
 the wanted constraint `Bar m m'` (from the use of `magic`) to `BarFamily m
 m' ~ 'True` (because of the `Bar` instance), and then it can no longer
 deduce that from `Bar m m'`. A peculiar scenario.

 It certainly looks wrong though, and FWIW GHC 7.6.3 accepts the program.

 The robust workaround is to add the superclass constraint `BarFamily m m'
 ~ 'True` to `Bar m m'`, since then (as you describe as "even more
 bizarrely") GHC can deduce either of `BarFamily m m' ~ 'True` and `Bar m
 m'` from the other, and then can't get stuck in this kind of situation.

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


More information about the ghc-tickets mailing list