Skip to content

Constraint solver panic due to derived type function equality

{-# LANGUAGE MultiParamTypeClasses, TypeFamilies #-}
{-# OPTIONS_GHC -ddump-tc-trace #-}

type family F (x :: *) :: *

class (y ~ F x) => C x y

z = () :: C x y => ()

causes a panic while tracing the typechecker:

solveNestedImplications starting {
  original inerts =  Equalities:
                     Type-function equalities: [D] _ :: F x_aeH ~ y_aeI (CFunEqCan)
                     Dictionaries: [W] $dC_aeK :: C x_aeH y_aeI (CDictCan)
                     Irreds:
                     Insolubles = {}
                     Solved dicts 0
                     Solved funeqs 0
  thinner_inerts  =  Equalities:ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20130812 for i386-unknown-linux):
	No match in record selector ctev_evar

If -ddump-tc-trace is not used, the correct constraint solving error is generated:

    Could not deduce (C x0 y0)
      arising from the ambiguity check for an expression type signature
    from the context (C x y)
      bound by an expression type signature: C x y => ()

It seems that prepareInertsForImplications in TcSMonad assumes that all the inert_funeqs are givens or wanteds; if there are some deriveds, then the above panic results.

Trac metadata
Trac field Value
Version 7.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Adam Gundry
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information