One can play funny games with GHC-3.00 and the following program
(a small fragment of a Happy-generated parser):

--------------------------------------------------------------------------
module Foo ( happyParse ) where

action_0 1 = \j tk _ -> action_1 j j tk (HappyState action_1)

action_1 3 = error "Bar"
action_1 _ = \i tk st@(HappyState action) sts stk -> action (-1) (-1) tk st sts (Just 
i : stk)

happyParse = action_0 2 2 '-' (HappyState action_0) [] [] 2

newtype HappyState b c =
   HappyState (Int -> Int -> b -> HappyState b c -> [HappyState b c] -> c)
--------------------------------------------------------------------------

  * Compiling it as-is with "ghc-3.00 -O -c Foo.hs" yields:
    => panic! (the `impossible' happened):
        fun_result_ty: 6 PrelBase.Int{-3f-}
                 -> PrelBase.Int{-3f-}
                 -> b_tr74
                 -> Foo.HappyState{-r6P-} b_tr74 c_tr75
                 -> [Foo.HappyState{-r6P-} b_tr74 c_tr75]
                 -> c_tr75

      Please report it as a compiler bug to [EMAIL PROTECTED]

  * If newtype is changed to data or "( happyParse )" is deleted,
    it compiles fine.

  * GHC-2.10 doesn't complain in any way.

  * If the first equation of action_1 is commented out, GHC seems to loop:
    ghc-3.00 -O -c Foo.hs -H50M -K50M
    => GHC's heap exhausted;
       while trying to allocate 20 bytes in a 50000000-byte heap;
       use the `-H<size>' option to increase the total heap size.

Cheers,
   Sven "Unhappy-too" Panne

-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne

Reply via email to