GHCi 5.04.2 segfaults on expression evaluation

Carlos Eduardo Scheidegger carlos.scheidegger@terra.com.br
07 Mar 2003 03:22:25 -0300


Hello. 

I think I've come across a GHCi bug.

Using the following module, GHCi version 5.04.2 segfaults, apparently
trying to compute a type using functional dependencies. The segfault
happens when I try to calculate (v1 .> v2). I tried the code on Hugs,
and it answers

Main> v1 .> v2
V [] :: PSOp (Pop a Id)

as expected. I think the problem is occuring in the line

> instance Reverse a b c => CheckPS Id a b c

because if I remove the line

> instance Reverse a (Pop t b)  c => Reverse (Pop t a) b c

instead of segfaulting, GHCi rightfully complains:

<interactive>:1:
    No instance for (Reverse (Pop a Id) Id c)
    arising from use of `.>' at <interactive>:1
    In the definition of `it': v1 .> v2


GHC compiles the program just fine and runs it without any issues. I
installed GHC 5.04.2 using the RedHat 8.0 RPM's. If there's any
important information you may need from me, please, tell me and I will
be glad to help. I've also cross-posted this to the bug section at
sourceforge.net, and there the module file can be found as a separate
file.

Thank you,
Carlos

--------------------------------------------------------------------------------

> class ComposePS a b c | a b -> c where
>     (.>) :: PSOp a -> PSOp b -> PSOp c
>     (V a) .> (V b) = V (a ++ b)

> instance (ConcatPS a b c, CheckPS c Id Id d) => ComposePS a b d

--------------------------------------------------------------------------------

> data PSOp a = V [String] deriving Show

> data Id
> data Push t rest
> data Pop t rest


> class Reverse a b c | a b -> c
> instance                           Reverse Id b b
> instance Reverse a (Pop t b)  c => Reverse (Pop t a) b c
> instance Reverse a (Push t b) c => Reverse (Push t a) b c

--------------------------------------------------------------------------------

> class ConcatPS a b c | a b -> c where
>     ccat :: a -> b -> c
> instance ConcatPS Id a a
> instance ConcatPS a b c => ConcatPS (Pop t a) b (Pop t c)
> instance ConcatPS a b c => ConcatPS (Push t a) b (Push t c)

--------------------------------------------------------------------------------

> class CheckPS a b c d | a b c -> d where
>     check :: a -> b -> c -> d
>     check _ _ _ = error "oki"

> instance Reverse a b c => CheckPS Id a b c

-- instance CheckPS a b (Push t c) d => CheckPS (Push t a) b c d

> instance CheckPS a (Pop t b) Id d => CheckPS (Pop t a) b Id d

-- instance CheckPS a b c d => CheckPS (Pop t a) b (Push t c) d

-- instance (SameType t1 t2, CheckPS a b c d) => CheckPS (Pop t1 a) b (Push t2 c) d

> u = undefined

> v1 :: PSOp (Pop a Id)
> v1 = V []

> v2 :: PSOp Id
> v2 = V []