[project @ 1998-12-21 10:45:36 by simonpj]
[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 GlaExts( trace )
15
16 #include "HsVersions.h"
17 \end{code}
18
19 \begin{code}
20 panic :: String -> a
21 panic x = error ("panic! (the `impossible' happened):\n\t"
22               ++ x ++ "\n\n"
23               ++ "Please report it as a compiler bug "
24               ++ "to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\n" )
25
26 -- #-versions because panic can't return an unboxed int, and that's
27 -- what TAG_ is with GHC at the moment.  Ugh. (Simon)
28 -- No, man -- Too Beautiful! (Will)
29
30 panic# :: String -> FAST_INT
31 panic# s = case (panic s) of () -> ILIT(0)
32
33 assertPanic :: String -> Int -> a
34 assertPanic file line = panic ("ASSERT failed! file " ++ file ++ ", line " ++ show line)
35 \end{code}