Opened 5 years ago

Closed 5 years ago

#5515 closed bug (fixed)

panic! (the 'impossible' happened) with evil self-referential instance

Reported by: andersk Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: indexed-types/should_fail/T5515
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This bit of code escaped from my fingertips:

{-# LANGUAGE ConstraintKinds, FlexibleInstances, TypeFamilies,
    UndecidableInstances #-}
class ctx (Arg ctx) => Some ctx where type Arg ctx
instance ctx a => Some ctx where type Arg ctx = a

and crashed GHC master with:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.3.20110927 for x86_64-unknown-linux):
	tcTyVarDetails a{tv aav} [tv]

Please report this as a GHC bug:

This causes a similar crash without using ConstraintKinds:

{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses,
    TypeFamilies, UndecidableInstances #-}
class C f a
class C f (Arg f) => Some f where type Arg f
instance C f a => Some f where type Arg f = a

Change History (2)

comment:1 Changed 5 years ago by simonpj@…

commit 817d1b047b538e408a8758a18270c51d429de670

Author: Simon Peyton Jones <>
Date:   Thu Sep 29 16:05:16 2011 +0100

    Fix scoping for RHS of associated type decls (fixes Trac #5515)
    We should not allow things like
    class C a b where
      type F a :: *
    instance C (p,q) r where
      type F (p,q) = r   -- No! fvs(rhs) should be a subset
                         --     of fvs(lhs)

 compiler/hsSyn/HsDecls.lhs   |   11 ++++++++---
 compiler/rename/RnSource.lhs |   42 ++++++++++++++++++++++++++----------------
 2 files changed, 34 insertions(+), 19 deletions(-)

comment:2 Changed 5 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: indexed-types/should_fail/T5515

Thanks very much for the report. Fixed!

Note: See TracTickets for help on using tickets.