Skip to content

Segfaults on levity-polymorphic type class

{-# Language FlexibleInstances, TypeFamilies, TypeInType, MagicHash #-}

import Data.Kind
import GHC.Exts

class Shw (a :: TYPE rep) where
  shw :: a -> String

instance Int# ~ a => Shw (a :: TYPE IntRep) where
  shw a = "I#" ++ show (I# a)

main = putStrLn (shw 3#)

induces a segfault

$ runghc --version
runghc 8.0.1
$ runghc test.hs
I#Segmentation fault
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information