Opened 7 years ago

Closed 7 years ago

#7384 closed bug (fixed)

Panic "ctEvTerm" when using functional dependencies and PolyKinds

Reported by: goldfire Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: FunctionalDependencies PolyKinds Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_compile/T7384
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following code causes a panic:

{-# LANGUAGE FunctionalDependencies, PolyKinds #-}

class Baz a b | a -> b where
  bar :: a -> ()

instance Baz Bool Bool where
  bar _ = ()

foo = bar False

The panic reads:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.7.20121031 for x86_64-apple-darwin):
	ctEvTerm: derived constraint cannot have id
<<details unavailable>>

The panic does not happen without -XPolyKinds.

Change History (4)

comment:1 Changed 7 years ago by simonpj@…

commit 545bb79667ebcbf5e776f76518cf68b4d507e7f5

Author: Simon Peyton Jones <>
Date:   Tue Nov 6 16:12:39 2012 +0000

    Refine the "kick-out" predicate for CTyVarEq
       Work item:   k ~ *
       Inert item:  (a::k) ~ Int
    Then we must kick out the inert item!  We weren't doing that,
    something I discovered when fixing Trac #7384.
    Discussed with Dimitrios, and we wrote a long comment
    Note [Delicate equality kick-out] to explain.

 compiler/typecheck/TcInteract.lhs |   67 +++++++++++++++++++++---------------
 1 files changed, 39 insertions(+), 28 deletions(-)

comment:2 Changed 7 years ago by simonpj@…

commit 4dade857ec0b1655b6297191b9262eb5174eec87

Author: Simon Peyton Jones <>
Date:   Tue Nov 6 16:03:11 2012 +0000

    Make rewriteCtFlavor lazy in the coercion for Derived evidence
    I think I accidentally introduced this bug a month ago when
    refactoring. It's a bit non-obvious, but since Derived constraints
    have no evidence, we mustn't be strict in it.  Now there's a big
    comment to prevent this bug happening again.
    This fixes Trac #7384.

 compiler/typecheck/TcSMonad.lhs |   66 ++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 29 deletions(-)

comment:3 Changed 7 years ago by simonpj

difficulty: Unknown
Status: newmerge
Test Case: typecheck/should_compile/T7384

Thanks. This bug doesn't exist in 7.6, so no need to merge the second patch. Ideally the first patch above should be merged if it goes across smoothly, but I'm not sure it's worth the effort. So I'll mark it "merge" provisionally.


comment:4 Changed 7 years ago by igloo

Resolution: fixed
Status: mergeclosed

Didn't apply cleanly, so not merging.

Note: See TracTickets for help on using tickets.