[GHC] #10166: GHCi: internal error: stg_ap_p_ret

GHC ghc-devs at haskell.org
Tue Mar 17 17:55:49 UTC 2015


#10166: GHCi: internal error: stg_ap_p_ret
-------------------------------------+-------------------------------------
              Reporter:              |             Owner:
  andreas.abel                       |            Status:  new
                  Type:  bug         |         Milestone:
              Priority:  normal      |           Version:  7.8.4
             Component:  GHCi        |  Operating System:  Unknown/Multiple
              Keywords:              |   Type of failure:  None/Unknown
          Architecture:              |        Blocked By:
  Unknown/Multiple                   |   Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
 {{{#!hs
 import Unsafe.Coerce
 coerce = Unsafe.Coerce.unsafeCoerce

 data Nat = Zero | Suc Nat

 fromNat :: Nat -> Integer
 fromNat Zero    = 0
 fromNat (Suc l) = 1 + fromNat l

 instance Show Nat where
   show l = show (fromNat l)

 data Exp = Const Nat | Pred | App Exp Exp

 eval :: Exp -> a
 eval (Const n) = coerce n
 eval e         = coerce $ evalP e
   where
     evalP Pred Zero    = Zero
     evalP Pred (Suc n) = n
     evalP e    n       = evalA e n

     evalA (App f e)    = eval f (eval e)
     evalA _            = error "eval"

 -- With type signature, result is 0 (wrong, should be 1)
 -- Without type signature: internal error: stg_ap_p_ret
 -- test :: Nat
 test = eval $ App Pred $ Const $ Suc $ Suc Zero

 -- main prints 0 should maybe print 1
 main :: IO ()
 main = print (coerce test :: Nat)
 }}}
 when evaluatiing test at the ghci prompt after loading, I get
 {{{
 <interactive>: internal error: stg_ap_p_ret
     (GHC version 7.8.3 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug

 Process haskell aborted (core dumped)
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10166>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list