Skip to content

Border case type families/type equality coercions cause the impossible to happen

A few border case problems with type equality coercions with type variables only occurring in the constraints part of the type. The code says it all.

{-# LANGUAGE TypeFamilies #-}
module Weird where

{- Compiles fine, but in GHCi:
Prelude Weird> :t x
*** Exception: No match in record selector Var.tcTyVarDetails
-}
x :: (a ~ b, Num b) => b
x = undefined

{- Same in GHCi, but when compiling:
% /tmp/ghc-6.8/bin/ghc --make Weird.hs
[1 of 1] Compiling Weird            ( Weird.hs, Weird.o )
ghc-6.8.0.20071002: panic! (the 'impossible' happened)
  (GHC version 6.8.0.20071002 for i386-unknown-linux):
          initC: srt_lbl

*Weird> plus 0 0
ghc-6.8.0.20071002: panic! (the 'impossible' happened)
  (GHC version 6.8.0.20071002 for i386-unknown-linux):
          nameModule $dNum{v arP}
-}
plus    :: (a ~ b, b ~ c, c ~ d, Num b) => b -> c -> d
plus x y = x + y

{- This one only works when plus is commented out, otherwise:
*Weird> y
ghc-6.8.0.20071002: panic! (the 'impossible' happened)
  (GHC version 6.8.0.20071002 for i386-unknown-linux):
          nameModule $dNum{v arY}
-}
y :: (a ~ a) => ()
y = ()
Trac metadata
Trac field Value
Version 6.8
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC rturk@science.uva.nl
Operating system
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information