Skip to content

Invalid usage of TypeFamilies cause GHC Internal Error

I couldn't be able to reproduce this with a valid program, but even on an invalid program seeing "GHC internal error" is unexpected. Only the second error should be enough in this case.

$ cat test.hs
{-# LANGUAGE TypeFamilies #-}

data Foo value
  = Foo (T value)

class Cl t where
  type T
  mk :: t -> T

main :: IO ()
main = undefined


$ runhaskell test.hs

test.hs:4:10: error:
    • GHC internal error: ‘T’ is not in scope during type checking, but it passed the renamer
      tcl_env of environment: [a10K :-> Type variable ‘value’ = value,
                               r10F :-> ATcTyCon Foo, r10G :-> APromotionErr RecDataConPE]
    • In the type ‘T value’
      In the definition of data constructor ‘Foo’
      In the data declaration for ‘Foo’

test.hs:6:1: error:
    • The associated type ‘T’
      mentions none of the type or kind variables of the class ‘Cl t’
    • In the class declaration for ‘Cl’


$ runhaskell --version
runghc 8.0.2
Edited by utdemir
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information