goldfirere / ghc

Mirror of ghc repository. DO NOT SUBMIT PULL REQUESTS HERE
http://www.haskell.org/ghc/
Other
25 stars 1 forks source link

Panic with GHC.TypeLits #58

Open vladfi1 opened 8 years ago

vladfi1 commented 8 years ago

The following short program caused a panic:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}

module Panic where

import GHC.TypeLits

type family TypeTable (s :: Symbol) :: k

class (KnownNat (Index t), t ~ TypeTable (Index t)) => Typeable t where
  type Index t :: Symbol

Here's the result:

Panic.hs:12:18: error:ghc: panic! (the 'impossible' happened)
  (GHC version 7.11.20151105 for x86_64-unknown-linux):
    AThing evaluated unexpectedly tcTyVar Index

The issue is that I accidentally used KnownNat instead of KnownSymbol.

goldfirere commented 8 years ago

Thanks for the report! My understanding is that this panic should happen only with type-incorrect code. It will be fixed, but if you ever see it, you know your code has a bug somewhere. (Not all that helpful, I know!)