[project @ 1997-07-05 01:39:03 by sof]
[ghc-hetmet.git] / ghc / compiler / utils / Util.lhs
index 734a321..6ed94ac 100644 (file)
@@ -87,7 +87,7 @@ module Util (
        -- error handling
 #if defined(COMPILING_GHC)
        , panic, panic#, pprPanic, pprPanic#, pprError, pprTrace
-       , assertPanic
+       , assertPanic, assertPprPanic
 #endif {- COMPILING_GHC -}
 
     ) where
@@ -96,6 +96,7 @@ module Util (
 
 CHK_Ubiq() -- debugging consistency check
 IMPORT_1_3(List(zipWith4))
+import Pretty  
 
 #else
 import List(zipWith4)
@@ -829,14 +830,14 @@ panic x = error ("panic! (the `impossible' happened):\n\t"
              ++ "Please report it as a compiler bug "
              ++ "to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\n" )
 
-pprPanic heading pretty_msg = panic (heading++(show pretty_msg))
-pprError heading pretty_msg = error (heading++(show pretty_msg))
+pprPanic heading pretty_msg = panic (heading++ " " ++ (show pretty_msg))
+pprError heading pretty_msg = error (heading++ " " ++ (show pretty_msg))
 #if __GLASGOW_HASKELL__ == 201
-pprTrace heading pretty_msg = GHCbase.trace (heading++(show pretty_msg))
+pprTrace heading pretty_msg = GHCbase.trace (heading++" "++(show pretty_msg))
 #elif __GLASGOW_HASKELL__ >= 202
-pprTrace heading pretty_msg = GlaExts.trace (heading++(show pretty_msg))
+pprTrace heading pretty_msg = GlaExts.trace (heading++" "++(show pretty_msg))
 #else
-pprTrace heading pretty_msg = trace (heading++(show pretty_msg))
+pprTrace heading pretty_msg = trace (heading++" "++(show pretty_msg))
 #endif
 
 -- #-versions because panic can't return an unboxed int, and that's
@@ -851,5 +852,12 @@ pprPanic# heading pretty_msg = panic# (heading++(show pretty_msg))
 assertPanic :: String -> Int -> a
 assertPanic file line = panic ("ASSERT failed! file "++file++", line "++show line)
 
+assertPprPanic :: String -> Int -> Doc -> a
+assertPprPanic file line msg
+  = panic (show (sep [hsep[text "ASSERT failed! file", 
+                          text file, 
+                          text "line", int line], 
+                     msg]))
+
 #endif {- COMPILING_GHC -}
 \end{code}