Skip to content

fromDynamic crashes ghci

Loading the following code into ghci and evaluating x
causes a segmentation fault:

data Foo a = Foo a

instance Typeable (Foo a) where
  typeOf x = mkAppTy (mkTyCon "BAD") []

x :: Maybe (Foo Char)
x = fromDynamic (toDyn (Foo "abc"))

This is not a problem for ghc.

The version of ghci is 5.00.2

I'm running on linux, not sure what vintage I'm afraid.

By the way, the reason I wrote this code was because I
was trying to figure out what role the type string
plays in the Dynamic library.  The documentation seems
to indicate that it is checked for equality every time
fromDyn or fromDynamic is called, but that doesn't seem
to be the case.  More documentation on what the string
does, and how to construct it correctly, would be
appreciated.  I was trying to figure out if I could
make this type Typeable:

data Name a = String




Trac metadata
Trac field Value
Version None
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
Component None
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