[commit: ghc] master: fix bug in :show bindings when a variable is bound to an exception (222589a)

Simon Marlow marlowsd at gmail.com
Wed Sep 21 10:54:31 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/222589a9f270d90f4ac21bf22b0a82e8ae126718

>---------------------------------------------------------------

commit 222589a9f270d90f4ac21bf22b0a82e8ae126718
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Sat Sep 17 13:06:36 2011 +0100

    fix bug in :show bindings when a variable is bound to an exception

>---------------------------------------------------------------

 compiler/ghci/Debugger.hs |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs
index e859609..c8946d6 100644
--- a/compiler/ghci/Debugger.hs
+++ b/compiler/ghci/Debugger.hs
@@ -27,6 +27,7 @@ import GHC
 import Outputable
 import PprTyThing
 import MonadUtils
+import Exception
 
 import Control.Monad
 import Data.List
@@ -209,8 +210,13 @@ pprTypeAndContents id = do
   if pcontents 
     then do
       let depthBound = 100
-      term      <- GHC.obtainTermFromId depthBound False id
-      docs_term <- showTerm term
+      -- If the value is an exception, make sure we catch it and
+      -- show the exception, rather than propagating the exception out.
+      e_term <- gtry $ GHC.obtainTermFromId depthBound False id
+      docs_term <- case e_term of
+                      Right term -> showTerm term
+                      Left  exn  -> return (text "*** Exception:" <+>
+                                            text (show (exn :: SomeException)))
       return $ pprdId <+> equals <+> docs_term
     else return pprdId
 





More information about the Cvs-ghc mailing list