1a7e90b5337167af58d14c2e19f92a5e574ac6bd
[ghc-hetmet.git] / ghc / compiler / utils / Panic.lhs
1 %
2 % (c) The GRASP Project, Glasgow University, 1992-1998
3 %
4 \section{Panic error messages}
5
6 Defines basic funtions for printing error messages.
7
8 It's hard to put these functions anywhere else without causing
9 some unnecessary loops in the module dependency graph.
10
11 \begin{code}
12 module Panic  ( panic, panic#, assertPanic, trace ) where
13
14 import IOExts ( trace )
15 import FastTypes
16
17 #include "HsVersions.h"
18 \end{code}
19
20 \begin{code}
21 panic :: String -> a
22 panic x = error ("panic! (the `impossible' happened):\n\t"
23               ++ x ++ "\n\n"
24               ++ "Please report it as a compiler bug "
25               ++ "to glasgow-haskell-bugs@haskell.org.\n\n" )
26
27 -- #-versions because panic can't return an unboxed int, and that's
28 -- what TAG_ is with GHC at the moment.  Ugh. (Simon)
29 -- No, man -- Too Beautiful! (Will)
30
31 panic# :: String -> FastInt
32 panic# s = case (panic s) of () -> _ILIT 0
33
34 assertPanic :: String -> Int -> a
35 assertPanic file line = panic ("ASSERT failed! file " ++ file ++ ", line " ++ show line)
36 \end{code}