diff options
author | Sven Tennie <sven.tennie@gmail.com> | 2021-10-21 12:23:16 +0200 |
---|---|---|
committer | Sven Tennie <sven.tennie@gmail.com> | 2022-02-09 09:29:02 +0100 |
commit | 4f9d9da3ebb0fe439866311eb6a52f3437aa7c61 (patch) | |
tree | fd500f2343e67e218954393bd1de3738d6311dce | |
parent | bd493ed6a63e41855f90c210f6cf1bace9199cf0 (diff) | |
download | haskell-4f9d9da3ebb0fe439866311eb6a52f3437aa7c61.tar.gz |
Replace SomeException with SomeExceptionWithLocation (#18159)
To keep backwards compatibility, for older GHC versions
SomeExceptionWithLocation is only a synonym for SomeException.
102 files changed, 275 insertions, 265 deletions
diff --git a/.gitmodules b/.gitmodules index c44e7335e5..f398fef8c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,7 @@ ignore = untracked [submodule "libraries/Cabal"] path = libraries/Cabal - url = https://gitlab.haskell.org/ghc/packages/Cabal.git + url = https://gitlab.haskell.org/supersven/Cabal.git ignore = untracked [submodule "libraries/containers"] path = libraries/containers @@ -16,7 +16,7 @@ ignore = untracked [submodule "libraries/haskeline"] path = libraries/haskeline - url = https://gitlab.haskell.org/ghc/packages/haskeline.git + url = https://gitlab.haskell.org/supersven/haskeline.git ignore = untracked [submodule "libraries/pretty"] path = libraries/pretty @@ -44,7 +44,7 @@ ignore = untracked [submodule "libraries/array"] path = libraries/array - url = https://gitlab.haskell.org/ghc/packages/array.git + url = https://gitlab.haskell.org/supersven/array.git ignore = untracked [submodule "libraries/deepseq"] path = libraries/deepseq @@ -52,7 +52,7 @@ ignore = untracked [submodule "libraries/directory"] path = libraries/directory - url = https://gitlab.haskell.org/ghc/packages/directory.git + url = https://gitlab.haskell.org/supersven/directory.git ignore = untracked [submodule "libraries/filepath"] path = libraries/filepath @@ -76,20 +76,20 @@ ignore = untracked [submodule "libraries/process"] path = libraries/process - url = https://gitlab.haskell.org/ghc/packages/process.git + url = https://gitlab.haskell.org/supersven/process.git ignore = untracked [submodule "libraries/unix"] path = libraries/unix - url = https://gitlab.haskell.org/ghc/packages/unix.git + url = https://gitlab.haskell.org/supersven/unix.git ignore = untracked branch = 2.7 [submodule "libraries/stm"] path = libraries/stm - url = https://gitlab.haskell.org/ghc/packages/stm.git + url = https://gitlab.haskell.org/supersven/stm.git ignore = untracked [submodule "utils/haddock"] path = utils/haddock - url = https://gitlab.haskell.org/ghc/haddock.git + url = https://gitlab.haskell.org/supersven/haddock.git ignore = untracked branch = ghc-head [submodule "nofib"] @@ -109,4 +109,4 @@ url = https://gitlab.haskell.org/ghc/gmp-tarballs.git [submodule "libraries/exceptions"] path = libraries/exceptions - url = https://gitlab.haskell.org/ghc/packages/exceptions.git + url = https://gitlab.haskell.org/supersven/exceptions.git diff --git a/compiler/GHC/Data/IOEnv.hs b/compiler/GHC/Data/IOEnv.hs index 836ca856d0..585bf7f38d 100644 --- a/compiler/GHC/Data/IOEnv.hs +++ b/compiler/GHC/Data/IOEnv.hs @@ -170,14 +170,14 @@ tryM (IOEnv thing) = IOEnv (\ env -> tryIOEnvFailure (thing env)) tryIOEnvFailure :: IO a -> IO (Either IOEnvFailure a) tryIOEnvFailure = try -tryAllM :: IOEnv env r -> IOEnv env (Either SomeException r) +tryAllM :: IOEnv env r -> IOEnv env (Either SomeExceptionWithLocation r) -- Catch *all* synchronous exceptions -- This is used when running a Template-Haskell splice, when -- even a pattern-match failure is a programmer error tryAllM (IOEnv thing) = IOEnv (\ env -> safeTry (thing env)) -- | Like 'try', but doesn't catch asynchronous exceptions -safeTry :: IO a -> IO (Either SomeException a) +safeTry :: IO a -> IO (Either SomeExceptionWithLocation a) safeTry act = do var <- newEmptyMVar -- uninterruptible because we want to mask around 'killThread', which is interruptible. @@ -185,13 +185,13 @@ safeTry act = do -- Fork, so that 'act' is safe from all asynchronous exceptions other than the ones we send it t <- forkIO $ try (restore act) >>= putMVar var restore (readMVar var) - `catchException` \(e :: SomeException) -> do + `catchException` \(e :: SomeExceptionWithLocation) -> do -- Control reaches this point only if the parent thread was sent an async exception -- In that case, kill the 'act' thread and re-raise the exception killThread t throwIO e -tryMostM :: IOEnv env r -> IOEnv env (Either SomeException r) +tryMostM :: IOEnv env r -> IOEnv env (Either SomeExceptionWithLocation r) tryMostM (IOEnv thing) = IOEnv (\ env -> tryMost (thing env)) --------------------------- diff --git a/compiler/GHC/Data/Maybe.hs b/compiler/GHC/Data/Maybe.hs index 3163829f75..0962890ac5 100644 --- a/compiler/GHC/Data/Maybe.hs +++ b/compiler/GHC/Data/Maybe.hs @@ -1,4 +1,5 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE KindSignatures #-} @@ -30,7 +31,6 @@ import GHC.IO (catchException) import Control.Monad import Control.Monad.Trans.Maybe -import Control.Exception (SomeException(..)) import Data.Maybe import Data.Foldable ( foldlM ) import GHC.Utils.Misc (HasCallStack) @@ -96,7 +96,7 @@ liftMaybeT act = MaybeT $ Just `liftM` act tryMaybeT :: IO a -> MaybeT IO a tryMaybeT action = MaybeT $ catchException (Just `fmap` action) handler where - handler (SomeException _) = return Nothing + handler (SomeExceptionWithLocation _) = return Nothing {- ************************************************************************ diff --git a/compiler/GHC/Prelude.hs b/compiler/GHC/Prelude.hs index f61dad9517..7067485ec4 100644 --- a/compiler/GHC/Prelude.hs +++ b/compiler/GHC/Prelude.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_HADDOCK not-home #-} +{-# LANGUAGE PatternSynonyms #-} -- | Custom GHC "Prelude" -- @@ -15,6 +16,12 @@ module GHC.Prelude (module X ,module Bits ,shiftL, shiftR +#if __GLASGOW_HASKELL__ < 903 + ,SomeExceptionWithLocation + ,pattern SomeExceptionWithLocation +#else + ,SomeExceptionWithLocation(..) +#endif ) where @@ -37,6 +44,11 @@ NoImplicitPrelude. There are two motivations for this: import Prelude as X hiding ((<>)) import Data.Foldable as X (foldl') +#if __GLASGOW_HASKELL__ < 903 +import Control.Exception ( Exception, SomeException(..) ) +#else +import Control.Exception ( SomeExceptionWithLocation(..) ) +#endif #if MIN_VERSION_base(4,16,0) import GHC.Bits as Bits hiding (shiftL, shiftR) @@ -86,3 +98,11 @@ shiftR = Bits.shiftR shiftL = Bits.unsafeShiftL shiftR = Bits.unsafeShiftR #endif + +#if __GLASGOW_HASKELL__ < 903 +type SomeExceptionWithLocation = SomeException + +{-# COMPLETE SomeExceptionWithLocation #-} +pattern SomeExceptionWithLocation :: () => forall e. Exception e => e -> SomeException +pattern SomeExceptionWithLocation e = SomeException e +#endif diff --git a/compiler/GHC/Runtime/Debugger.hs b/compiler/GHC/Runtime/Debugger.hs index 04709b38cf..60f56f52b7 100644 --- a/compiler/GHC/Runtime/Debugger.hs +++ b/compiler/GHC/Runtime/Debugger.hs @@ -34,7 +34,6 @@ import GHC.Core.Type import GHC.Utils.Outputable import GHC.Utils.Error import GHC.Utils.Monad -import GHC.Utils.Exception import GHC.Utils.Logger import GHC.Types.Id @@ -265,6 +264,6 @@ pprTypeAndContents id = do docs_term <- case e_term of Right term -> showTerm term Left exn -> return (text "*** Exception:" <+> - text (show (exn :: SomeException))) + text (show (exn :: GHC.Prelude.SomeExceptionWithLocation))) return $ pprdId <+> equals <+> docs_term else return pprdId diff --git a/compiler/GHC/Runtime/Eval/Types.hs b/compiler/GHC/Runtime/Eval/Types.hs index 85fd1c8037..cf85eb0370 100644 --- a/compiler/GHC/Runtime/Eval/Types.hs +++ b/compiler/GHC/Runtime/Eval/Types.hs @@ -22,7 +22,6 @@ import GHC.Types.TyThing import GHC.Types.BreakInfo import GHC.Types.Name.Reader import GHC.Types.SrcLoc -import GHC.Utils.Exception import Data.Word import GHC.Stack.CCS @@ -46,7 +45,7 @@ isStep _ = True data ExecResult = ExecComplete - { execResult :: Either SomeException [Name] + { execResult :: Either SomeExceptionWithLocation [Name] , execAllocation :: Word64 } | ExecBreak diff --git a/compiler/GHC/Runtime/Interpreter.hs b/compiler/GHC/Runtime/Interpreter.hs index 2c84980513..90b2daf16a 100644 --- a/compiler/GHC/Runtime/Interpreter.hs +++ b/compiler/GHC/Runtime/Interpreter.hs @@ -537,21 +537,21 @@ findSystemLibrary interp str = interpCmd interp (FindSystemLibrary str) iservCall :: Binary a => IServInstance -> Message a -> IO a iservCall iserv msg = remoteCall (iservPipe iserv) msg - `catchException` \(e :: SomeException) -> handleIServFailure iserv e + `catchException` \(e :: SomeExceptionWithLocation) -> handleIServFailure iserv e -- | Read a value from the iserv process readIServ :: IServInstance -> Get a -> IO a readIServ iserv get = readPipe (iservPipe iserv) get - `catchException` \(e :: SomeException) -> handleIServFailure iserv e + `catchException` \(e :: SomeExceptionWithLocation) -> handleIServFailure iserv e -- | Send a value to the iserv process writeIServ :: IServInstance -> Put -> IO () writeIServ iserv put = writePipe (iservPipe iserv) put - `catchException` \(e :: SomeException) -> handleIServFailure iserv e + `catchException` \(e :: SomeExceptionWithLocation) -> handleIServFailure iserv e -handleIServFailure :: IServInstance -> SomeException -> IO a +handleIServFailure :: IServInstance -> SomeExceptionWithLocation -> IO a handleIServFailure iserv e = do let proc = iservProcess iserv ex <- getProcessExitCode proc diff --git a/compiler/GHC/SysTools/Process.hs b/compiler/GHC/SysTools/Process.hs index 63ff2c8294..2b67233b63 100644 --- a/compiler/GHC/SysTools/Process.hs +++ b/compiler/GHC/SysTools/Process.hs @@ -63,7 +63,7 @@ readCreateProcessWithExitCode' proc = do -- fork off a thread to start consuming the output outMVar <- newEmptyMVar - let onError :: SomeException -> IO () + let onError :: SomeExceptionWithLocation -> IO () onError exc = putMVar outMVar (Left exc) _ <- forkIO $ handle onError $ do output <- hGetContents' outh @@ -281,7 +281,7 @@ builderMainLoop logger filter_fn pgm real_args mb_cwd mb_env = do inner hProcess case r of -- onException - Left (SomeException e) -> do + Left (SomeExceptionWithLocation e) -> do terminateProcess hProcess cleanup_handles throw e diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs index 73b3835282..7e6d30885a 100644 --- a/compiler/GHC/SysTools/Tasks.hs +++ b/compiler/GHC/SysTools/Tasks.hs @@ -206,7 +206,7 @@ runClang logger dflags args = traceToolCommand logger "clang" $ do mb_env <- getGccEnv args2 catchException (runSomethingFiltered logger id "Clang (Assembler)" clang args2 Nothing mb_env) - (\(err :: SomeException) -> do + (\(err :: SomeExceptionWithLocation) -> do errorMsg logger $ text ("Error running clang! you need clang installed to use the" ++ " LLVM backend") $+$ diff --git a/compiler/GHC/Types/Demand.hs b/compiler/GHC/Types/Demand.hs index 7376a610d4..1c53103128 100644 --- a/compiler/GHC/Types/Demand.hs +++ b/compiler/GHC/Types/Demand.hs @@ -1406,7 +1406,7 @@ is not strict in its argument: Just try this in GHCi :set -XScopedTypeVariables import Control.Exception - catch undefined (\(_ :: SomeException) -> putStrLn "you'll see this") + catch undefined (\(_ :: SomeExceptionWithLocation) -> putStrLn "you'll see this") Any analysis that assumes otherwise will be broken in some way or another (beyond `-fno-pendantic-bottoms`). diff --git a/compiler/GHC/Utils/Panic.hs b/compiler/GHC/Utils/Panic.hs index 398a97524c..13fccb22b2 100644 --- a/compiler/GHC/Utils/Panic.hs +++ b/compiler/GHC/Utils/Panic.hs @@ -110,7 +110,7 @@ data GhcException | PprProgramError String SDoc instance Exception GhcException where - fromException (SomeException e) + fromException (SomeExceptionWithLocation e) | Just ge <- cast e = Just ge | Just pge <- cast e = Just $ case pge of @@ -138,7 +138,7 @@ safeShowException e = do r <- try (return $! forceList (showException e)) case r of Right msg -> return msg - Left e' -> safeShowException (e' :: SomeException) + Left e' -> safeShowException (e' :: SomeExceptionWithLocation) where forceList [] = [] forceList xs@(x : xt) = x `seq` forceList xt `seq` xs @@ -196,7 +196,7 @@ pgmErrorDoc x doc = throwGhcException (PprProgramError x doc) -- | Like try, but pass through UserInterrupt and Panic exceptions. -- Used when we want soft failures when reading interface files, for example. -- TODO: I'm not entirely sure if this is catching what we really want to catch -tryMost :: IO a -> IO (Either SomeException a) +tryMost :: IO a -> IO (Either SomeExceptionWithLocation a) tryMost action = do r <- try action case r of Left se -> diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 4043f3e247..20bf8ce399 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1048,7 +1048,7 @@ installInteractivePrint (Just ipFun) exprmode = do runCommands :: InputT GHCi (Maybe String) -> InputT GHCi () runCommands gCmd = runCommands' handler Nothing gCmd >> return () -runCommands' :: (SomeException -> GHCi Bool) -- ^ Exception handler +runCommands' :: (SomeExceptionWithLocation -> GHCi Bool) -- ^ Exception handler -> Maybe (GHCi ()) -- ^ Source error handler -> InputT GHCi (Maybe String) -> InputT GHCi () @@ -1074,7 +1074,7 @@ runCommands' eh sourceErrorHandler gCmd = mask $ \unmask -> do -- this is relevant only to ghc -e, which will exit with status 1 -- if the command was unsuccessful. GHCi will continue in either case. -- TODO: replace Bool with CmdExecOutcome -runOneCommand :: (SomeException -> GHCi Bool) -> InputT GHCi (Maybe String) +runOneCommand :: (SomeExceptionWithLocation -> GHCi Bool) -> InputT GHCi (Maybe String) -> InputT GHCi (Maybe Bool) runOneCommand eh gCmd = do -- run a previously queued command if there is one, otherwise get new @@ -2241,7 +2241,7 @@ keepPackageImports = filterM is_pkg_import is_pkg_import (IIDecl d) = do pkgqual <- GHC.renameRawPkgQualM (unLoc $ ideclName d) (ideclPkgQual d) e <- MC.try $ GHC.findQualifiedModule pkgqual mod_name - case e :: Either SomeException Module of + case e :: Either SomeExceptionWithLocation Module of Left _ -> return False Right m -> return (not (isMainUnitModule m)) where @@ -4080,7 +4080,7 @@ breakById inp = do let (mod_str, top_level, fun_str) = splitIdent inp mod_top_lvl = combineModIdent mod_str top_level mb_mod <- catch (lookupModuleInscope mod_top_lvl) - (\(_ :: SomeException) -> lookupModuleInGraph mod_str) + (\(_ :: SomeExceptionWithLocation) -> lookupModuleInGraph mod_str) -- If the top-level name is not in scope, `lookupModuleInscope` will -- throw an exception, then lookup the module name in the module graph. mb_err_msg <- validateBP mod_str fun_str mb_mod @@ -4493,13 +4493,13 @@ setBreakFlag md ix enaDisa = do -- raising another exception. We therefore don't put the recursive -- handler around the flushing operation, so if stderr is closed -- GHCi will just die gracefully rather than going into an infinite loop. -handler :: GhciMonad m => SomeException -> m Bool +handler :: GhciMonad m => SomeExceptionWithLocation -> m Bool handler exception = do flushInterpBuffers withSignalHandlers $ ghciHandle handler (showException exception >> return False) -showException :: MonadIO m => SomeException -> m () +showException :: MonadIO m => SomeExceptionWithLocation -> m () showException se = liftIO $ case fromException se of -- omit the location for CmdLineError: @@ -4531,13 +4531,13 @@ printErrAndMaybeExit = (>> failIfExprEvalMode) . GHC.printException -- in an exception loop (eg. let a = error a in a) the ^C exception -- may never be delivered. Thanks to Marcin for pointing out the bug. -ghciHandle :: (HasLogger m, ExceptionMonad m) => (SomeException -> m a) -> m a -> m a +ghciHandle :: (HasLogger m, ExceptionMonad m) => (SomeExceptionWithLocation -> m a) -> m a -> m a ghciHandle h m = mask $ \restore -> do -- Force dflags to avoid leaking the associated HscEnv !log <- getLogger catch (restore (GHC.prettyPrintGhcErrors log m)) $ \e -> restore (h e) -ghciTry :: ExceptionMonad m => m a -> m (Either SomeException a) +ghciTry :: ExceptionMonad m => m a -> m (Either SomeExceptionWithLocation a) ghciTry m = fmap Right m `catch` \e -> return $ Left e tryBool :: ExceptionMonad m => m a -> m Bool diff --git a/ghc/GHCi/UI/Info.hs b/ghc/GHCi/UI/Info.hs index 7fb13316e9..f793c20374 100644 --- a/ghc/GHCi/UI/Info.hs +++ b/ghc/GHCi/UI/Info.hs @@ -276,7 +276,7 @@ collectInfo ms loaded = do where go df unit_state m name = do { info <- getModInfo name; return (M.insert name info m) } `MC.catch` - (\(e :: SomeException) -> do + (\(e :: SomeExceptionWithLocation) -> do liftIO $ putStrLn $ showSDocForUser df unit_state alwaysQualify $ "Error while getting type info from" <+> diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs index aede0a9dc1..f397a1c70b 100644 --- a/ghc/GHCi/UI/Monad.hs +++ b/ghc/GHCi/UI/Monad.hs @@ -201,7 +201,7 @@ data CmdExecOutcome data CommandResult = CommandComplete { cmdInput :: String - , cmdResult :: Either SomeException (Maybe Bool) + , cmdResult :: Either SomeExceptionWithLocation (Maybe Bool) , cmdStats :: ActionStats } | CommandIncomplete @@ -441,7 +441,7 @@ runAndPrintStats :: GhciMonad m => (a -> Maybe Integer) -> m a - -> m (ActionStats, Either SomeException a) + -> m (ActionStats, Either SomeExceptionWithLocation a) runAndPrintStats getAllocs action = do result <- runWithStats getAllocs action case result of @@ -455,7 +455,7 @@ runAndPrintStats getAllocs action = do runWithStats :: ExceptionMonad m - => (a -> Maybe Integer) -> m a -> m (ActionStats, Either SomeException a) + => (a -> Maybe Integer) -> m a -> m (ActionStats, Either SomeExceptionWithLocation a) runWithStats getAllocs action = do t0 <- liftIO getCurrentTime result <- MC.try action diff --git a/hadrian/src/Main.hs b/hadrian/src/Main.hs index d2e0ace795..dddb0aaa42 100644 --- a/hadrian/src/Main.hs +++ b/hadrian/src/Main.hs @@ -134,7 +134,7 @@ handleShakeException shake_opts_var shake_run = do then hPrint stderr _e else - -- The SomeException here is normally an IOError which lacks + -- The SomeExceptionWithLocation here is normally an IOError which lacks -- very much structure, in the future we could try to catch -- a more structured exception and further refine the -- displayed output. https://github.com/ndmitchell/shake/pull/812 @@ -150,4 +150,3 @@ escNormal = "\ESC[0m" escape :: String -> String -> String escape code x = escForeground code ++ x ++ escNormal - diff --git a/libraries/Cabal b/libraries/Cabal -Subproject 9d9fe65d1e6db56004a00f1908207d5ea4ed18d +Subproject c5af55a047e26bfe2b7377194771b87bbe3f30f diff --git a/libraries/array b/libraries/array -Subproject 3e4334a6f39d92090bf3ded86b84d7cd1817ce2 +Subproject 1dd664de29fbd2e07de4a543a37d5b2ee7265a9 diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index bd222e2b1e..2b2e3344f8 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -195,7 +195,7 @@ attribute will block all other threads. -- terminates, for example. -- -- @since 4.6.0.0 -forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId +forkFinally :: IO a -> (Either SomeExceptionWithLocation a -> IO ()) -> IO ThreadId forkFinally action and_then = mask $ \restore -> forkIO $ try (restore action) >>= and_then @@ -382,12 +382,12 @@ runInUnboundThread action = do mv <- newEmptyMVar mask $ \restore -> do tid <- forkIO $ Exception.try (restore action) >>= putMVar mv - let wait = takeMVar mv `catchException` \(e :: SomeException) -> + let wait = takeMVar mv `catchException` \(e :: SomeExceptionWithLocation) -> Exception.throwTo tid e >> wait wait >>= unsafeResult else action -unsafeResult :: Either SomeException a -> IO a +unsafeResult :: Either SomeExceptionWithLocation a -> IO a unsafeResult = either Exception.throwIO return -- --------------------------------------------------------------------------- diff --git a/libraries/base/Control/Exception.hs b/libraries/base/Control/Exception.hs index a84005e536..adbc2f14d0 100644 --- a/libraries/base/Control/Exception.hs +++ b/libraries/base/Control/Exception.hs @@ -34,7 +34,7 @@ module Control.Exception ( -- * The Exception type - SomeException(..), + SomeExceptionWithLocation(..), Exception(..), -- class IOException, -- instance Eq, Ord, Show, Typeable, Exception ArithException(..), -- instance Eq, Ord, Show, Typeable, Exception @@ -166,7 +166,7 @@ Instead, we provide a function 'catches', which would be used thus: catches :: IO a -> [Handler a] -> IO a catches io handlers = io `catch` catchesHandler handlers -catchesHandler :: [Handler a] -> SomeException -> IO a +catchesHandler :: [Handler a] -> SomeExceptionWithLocation -> IO a catchesHandler handlers e = foldr tryHandler (throw e) handlers where tryHandler (Handler handler) res = case fromException e of @@ -355,9 +355,9 @@ The following operations are guaranteed not to be interruptible: {- $catchall -It is possible to catch all exceptions, by using the type 'SomeException': +It is possible to catch all exceptions, by using the type 'SomeExceptionWithLocation': -> catch f (\e -> ... (e :: SomeException) ...) +> catch f (\e -> ... (e :: SomeExceptionWithLocation) ...) HOWEVER, this is normally not what you want to do! @@ -393,6 +393,5 @@ see what the exception is. One example is at the very top-level of a program, you may wish to catch any exception, print it to a logfile or the screen, and then exit gracefully. For these cases, you can use 'catch' (or one of the other exception-catching functions) with the -'SomeException' type. +'SomeExceptionWithLocation' type. -} - diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index 35218c4ffb..31bf113f7d 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -19,7 +19,7 @@ module Control.Exception.Base ( -- * The Exception type - SomeException(..), + SomeExceptionWithLocation(..), Exception(..), IOException, ArithException(..), @@ -190,7 +190,7 @@ tryJust p a = do -- exception raised by the computation. onException :: IO a -> IO b -> IO a onException io what = io `catch` \e -> do _ <- what - throwIO (e :: SomeException) + throwIO (e :: SomeExceptionWithLocation) ----------------------------------------------------------------------------- -- Some Useful Functions @@ -408,9 +408,9 @@ patError s = throw (PatternMatchFail (untangle s "Non-exhaustive typeError s = throw (TypeError (unpackCStringUtf8# s)) -- GHC's RTS calls this -nonTermination :: SomeException +nonTermination :: SomeExceptionWithLocation nonTermination = toException NonTermination -- GHC's RTS calls this -nestedAtomically :: SomeException +nestedAtomically :: SomeExceptionWithLocation nestedAtomically = toException NestedAtomically diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs index 99df92daed..1164ba6dde 100644 --- a/libraries/base/GHC/Conc/Sync.hs +++ b/libraries/base/GHC/Conc/Sync.hs @@ -391,14 +391,14 @@ numSparks = IO $ \s -> case numSparks# s of (# s', n #) -> (# s', I# n #) foreign import ccall "&enabled_capabilities" enabled_capabilities :: Ptr CInt -childHandler :: SomeException -> IO () +childHandler :: SomeExceptionWithLocation -> IO () childHandler err = catch (real_handler err) childHandler -- We must use catch here rather than catchException. If the -- raised exception throws an (imprecise) exception, then real_handler err -- will do so as well. If we use catchException here, then we could miss -- that exception. -real_handler :: SomeException -> IO () +real_handler :: SomeExceptionWithLocation -> IO () real_handler se | Just BlockedIndefinitelyOnMVar <- fromException se = return () | Just BlockedIndefinitelyOnSTM <- fromException se = return () @@ -888,7 +888,7 @@ reportStackOverflow = do ThreadId tid <- myThreadId c_reportStackOverflow tid -reportError :: SomeException -> IO () +reportError :: SomeExceptionWithLocation -> IO () reportError ex = do handler <- getUncaughtExceptionHandler handler ex @@ -902,11 +902,11 @@ foreign import ccall unsafe "reportHeapOverflow" reportHeapOverflow :: IO () {-# NOINLINE uncaughtExceptionHandler #-} -uncaughtExceptionHandler :: IORef (SomeException -> IO ()) +uncaughtExceptionHandler :: IORef (SomeExceptionWithLocation -> IO ()) uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler) where - defaultHandler :: SomeException -> IO () - defaultHandler se@(SomeException ex) = do + defaultHandler :: SomeExceptionWithLocation -> IO () + defaultHandler se@(SomeExceptionWithLocation ex) = do (hFlush stdout) `catchAny` (\ _ -> return ()) let msg = case cast ex of Just Deadlock -> "no threads to run: infinite loop or deadlock?" @@ -920,8 +920,8 @@ uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler) foreign import ccall unsafe "HsBase.h errorBelch2" errorBelch :: CString -> CString -> IO () -setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO () +setUncaughtExceptionHandler :: (SomeExceptionWithLocation -> IO ()) -> IO () setUncaughtExceptionHandler = writeIORef uncaughtExceptionHandler -getUncaughtExceptionHandler :: IO (SomeException -> IO ()) +getUncaughtExceptionHandler :: IO (SomeExceptionWithLocation -> IO ()) getUncaughtExceptionHandler = readIORef uncaughtExceptionHandler diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs index a330225622..3f6bb7659f 100644 --- a/libraries/base/GHC/Event/Thread.hs +++ b/libraries/base/GHC/Event/Thread.hs @@ -16,7 +16,7 @@ module GHC.Event.Thread , blockedOnBadFD -- used by RTS ) where -- TODO: Use new Windows I/O manager -import Control.Exception (finally, SomeException, toException) +import Control.Exception (finally, SomeExceptionWithLocation, toException) import Data.Foldable (forM_, mapM_, sequence_) import Data.IORef (IORef, newIORef, readIORef, writeIORef) import Data.Maybe (fromMaybe) @@ -126,7 +126,7 @@ threadWait evt fd = mask_ $ do else return () -- used at least by RTS in 'select()' IO manager backend -blockedOnBadFD :: SomeException +blockedOnBadFD :: SomeExceptionWithLocation blockedOnBadFD = toException $ errnoToIOError "awaitEvent" eBADF Nothing Nothing threadWaitSTM :: Event -> Fd -> IO (STM (), IO ()) diff --git a/libraries/base/GHC/Event/Windows.hsc b/libraries/base/GHC/Event/Windows.hsc index b22fa8d877..64644161ee 100644 --- a/libraries/base/GHC/Event/Windows.hsc +++ b/libraries/base/GHC/Event/Windows.hsc @@ -664,7 +664,7 @@ withOverlappedEx mgr fname h async offset startCB completionCB = do let cancel e = do nerr <- getLastError debugIO $ "## Exception occurred. Cancelling request... " - debugIO $ show (e :: SomeException) ++ " : " ++ show nerr + debugIO $ show (e :: SomeExceptionWithLocation) ++ " : " ++ show nerr _ <- uninterruptibleMask_ $ FFI.cancelIoEx' h lpol -- we need to wait for the cancellation before removing -- the pointer. diff --git a/libraries/base/GHC/Exception.hs b/libraries/base/GHC/Exception.hs index abaa308aec..c359dcbdf7 100644 --- a/libraries/base/GHC/Exception.hs +++ b/libraries/base/GHC/Exception.hs @@ -74,10 +74,10 @@ instance Show ErrorCall where showsPrec _ (ErrorCallWithLocation err loc) = showString err . showChar '\n' . showString loc -errorCallException :: String -> SomeException +errorCallException :: String -> SomeExceptionWithLocation errorCallException s = toException (ErrorCall s) -errorCallWithCallStackException :: String -> CallStack -> SomeException +errorCallWithCallStackException :: String -> CallStack -> SomeExceptionWithLocation errorCallWithCallStackException s stk = unsafeDupablePerformIO $ do ccsStack <- currentCallStack let diff --git a/libraries/base/GHC/Exception.hs-boot b/libraries/base/GHC/Exception.hs-boot index 86502c9ae6..e26566f277 100644 --- a/libraries/base/GHC/Exception.hs-boot +++ b/libraries/base/GHC/Exception.hs-boot @@ -34,5 +34,5 @@ import {-# SOURCE #-} GHC.Exception.Type import GHC.Types ( Char ) import GHC.Stack.Types ( CallStack ) -errorCallException :: [Char] -> SomeException -errorCallWithCallStackException :: [Char] -> CallStack -> SomeException +errorCallException :: [Char] -> SomeExceptionWithLocation +errorCallWithCallStackException :: [Char] -> CallStack -> SomeExceptionWithLocation diff --git a/libraries/base/GHC/Exception/Type.hs b/libraries/base/GHC/Exception/Type.hs index 642e1a9889..58844c3681 100644 --- a/libraries/base/GHC/Exception/Type.hs +++ b/libraries/base/GHC/Exception/Type.hs @@ -20,7 +20,7 @@ module GHC.Exception.Type ( Exception(..) -- Class - , SomeException(..), ArithException(..) + , SomeExceptionWithLocation(..), SomeException, ArithException(..) , divZeroException, overflowException, ratioZeroDenomException , underflowException ) where @@ -32,15 +32,17 @@ import GHC.Base import GHC.Show {- | -The @SomeException@ type is the root of the exception type hierarchy. +The @SomeExceptionWithLocation@ type is the root of the exception type hierarchy. When an exception of type @e@ is thrown, behind the scenes it is -encapsulated in a @SomeException@. +encapsulated in a @SomeExceptionWithLocation@. -} -data SomeException = forall e . Exception e => SomeException e +data SomeExceptionWithLocation = forall e . Exception e => SomeExceptionWithLocation e + +type SomeException = SomeExceptionWithLocation -- | @since 3.0 -instance Show SomeException where - showsPrec p (SomeException e) = showsPrec p e +instance Show SomeExceptionWithLocation where + showsPrec p (SomeExceptionWithLocation e) = showsPrec p e {- | Any type that you wish to throw or catch as an exception must be an @@ -74,10 +76,10 @@ of exceptions: > > instance Exception SomeCompilerException > -> compilerExceptionToException :: Exception e => e -> SomeException +> compilerExceptionToException :: Exception e => e -> SomeExceptionWithLocation > compilerExceptionToException = toException . SomeCompilerException > -> compilerExceptionFromException :: Exception e => SomeException -> Maybe e +> compilerExceptionFromException :: Exception e => SomeExceptionWithLocation -> Maybe e > compilerExceptionFromException x = do > SomeCompilerException a <- fromException x > cast a @@ -94,10 +96,10 @@ of exceptions: > toException = compilerExceptionToException > fromException = compilerExceptionFromException > -> frontendExceptionToException :: Exception e => e -> SomeException +> frontendExceptionToException :: Exception e => e -> SomeExceptionWithLocation > frontendExceptionToException = toException . SomeFrontendException > -> frontendExceptionFromException :: Exception e => SomeException -> Maybe e +> frontendExceptionFromException :: Exception e => SomeExceptionWithLocation -> Maybe e > frontendExceptionFromException x = do > SomeFrontendException a <- fromException x > cast a @@ -129,11 +131,11 @@ Caught MismatchedParentheses -} class (Typeable e, Show e) => Exception e where - toException :: e -> SomeException - fromException :: SomeException -> Maybe e + toException :: e -> SomeExceptionWithLocation + fromException :: SomeExceptionWithLocation -> Maybe e - toException = SomeException - fromException (SomeException e) = cast e + toException = SomeExceptionWithLocation + fromException (SomeExceptionWithLocation e) = cast e -- | Render this exception value in a human-friendly manner. -- @@ -144,10 +146,10 @@ class (Typeable e, Show e) => Exception e where displayException = show -- | @since 3.0 -instance Exception SomeException where +instance Exception SomeExceptionWithLocation where toException se = se fromException = Just - displayException (SomeException e) = displayException e + displayException (SomeExceptionWithLocation e) = displayException e -- |Arithmetic exceptions. data ArithException @@ -161,7 +163,7 @@ data ArithException , Ord -- ^ @since 3.0 ) -divZeroException, overflowException, ratioZeroDenomException, underflowException :: SomeException +divZeroException, overflowException, ratioZeroDenomException, underflowException :: SomeExceptionWithLocation divZeroException = toException DivideByZero overflowException = toException Overflow ratioZeroDenomException = toException RatioZeroDenominator diff --git a/libraries/base/GHC/Exception/Type.hs-boot b/libraries/base/GHC/Exception/Type.hs-boot index b47fb46b49..0d6d48635a 100644 --- a/libraries/base/GHC/Exception/Type.hs-boot +++ b/libraries/base/GHC/Exception/Type.hs-boot @@ -2,7 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} module GHC.Exception.Type - ( SomeException + ( SomeExceptionWithLocation , divZeroException , overflowException , ratioZeroDenomException @@ -11,6 +11,6 @@ module GHC.Exception.Type import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Base -data SomeException +data SomeExceptionWithLocation divZeroException, overflowException, - ratioZeroDenomException, underflowException :: SomeException + ratioZeroDenomException, underflowException :: SomeExceptionWithLocation diff --git a/libraries/base/GHC/IO.hs b/libraries/base/GHC/IO.hs index 283020d973..31b5b179da 100644 --- a/libraries/base/GHC/IO.hs +++ b/libraries/base/GHC/IO.hs @@ -194,7 +194,7 @@ catch (IO io) handler = IO $ catch# io handler' -- details. catchAny :: IO a -> (forall e . Exception e => e -> IO a) -> IO a catchAny !(IO io) handler = IO $ catch# io handler' - where handler' (SomeException e) = unIO (handler e) + where handler' (SomeExceptionWithLocation e) = unIO (handler e) -- Using catchException here means that if `m` throws an -- 'IOError' /as an imprecise exception/, we will not catch @@ -293,7 +293,7 @@ getMaskingState = IO $ \s -> onException :: IO a -> IO b -> IO a onException io what = io `catchException` \e -> do _ <- what - throwIO (e :: SomeException) + throwIO (e :: SomeExceptionWithLocation) -- | Executes an IO computation with asynchronous -- exceptions /masked/. That is, any thread which attempts to raise @@ -442,9 +442,9 @@ Laziness can interact with @catch@-like operations in non-obvious ways (see, e.g. GHC #11555 and #13330). For instance, consider these subtly-different examples: -> test1 = Control.Exception.catch (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") +> test1 = Control.Exception.catch (error "uh oh") (\(_ :: SomeExceptionWithLocation) -> putStrLn "it failed") > -> test2 = GHC.IO.catchException (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") +> test2 = GHC.IO.catchException (error "uh oh") (\(_ :: SomeExceptionWithLocation) -> putStrLn "it failed") While @test1@ will print "it failed", @test2@ will print "uh oh". @@ -458,5 +458,5 @@ use 'catch' rather than 'catchException'. -} -- For SOURCE import by GHC.Base to define failIO. -mkUserError :: [Char] -> SomeException +mkUserError :: [Char] -> SomeExceptionWithLocation mkUserError str = toException (userError str) diff --git a/libraries/base/GHC/IO.hs-boot b/libraries/base/GHC/IO.hs-boot index 1629050d93..9dc5003b4f 100644 --- a/libraries/base/GHC/IO.hs-boot +++ b/libraries/base/GHC/IO.hs-boot @@ -4,7 +4,7 @@ module GHC.IO where import GHC.Types -import {-# SOURCE #-} GHC.Exception.Type (SomeException) +import {-# SOURCE #-} GHC.Exception.Type (SomeExceptionWithLocation) mplusIO :: IO a -> IO a -> IO a -mkUserError :: [Char] -> SomeException +mkUserError :: [Char] -> SomeExceptionWithLocation diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs index 758a84bf32..152177434a 100644 --- a/libraries/base/GHC/IO/Exception.hs +++ b/libraries/base/GHC/IO/Exception.hs @@ -74,7 +74,7 @@ instance Exception BlockedIndefinitelyOnMVar instance Show BlockedIndefinitelyOnMVar where showsPrec _ BlockedIndefinitelyOnMVar = showString "thread blocked indefinitely in an MVar operation" -blockedIndefinitelyOnMVar :: SomeException -- for the RTS +blockedIndefinitelyOnMVar :: SomeExceptionWithLocation -- for the RTS blockedIndefinitelyOnMVar = toException BlockedIndefinitelyOnMVar ----- @@ -90,7 +90,7 @@ instance Exception BlockedIndefinitelyOnSTM instance Show BlockedIndefinitelyOnSTM where showsPrec _ BlockedIndefinitelyOnSTM = showString "thread blocked indefinitely in an STM transaction" -blockedIndefinitelyOnSTM :: SomeException -- for the RTS +blockedIndefinitelyOnSTM :: SomeExceptionWithLocation -- for the RTS blockedIndefinitelyOnSTM = toException BlockedIndefinitelyOnSTM ----- @@ -125,7 +125,7 @@ instance Show AllocationLimitExceeded where showsPrec _ AllocationLimitExceeded = showString "allocation limit exceeded" -allocationLimitExceeded :: SomeException -- for the RTS +allocationLimitExceeded :: SomeExceptionWithLocation -- for the RTS allocationLimitExceeded = toException AllocationLimitExceeded ----- @@ -145,15 +145,15 @@ instance Show CompactionFailed where showsPrec _ (CompactionFailed why) = showString ("compaction failed: " ++ why) -cannotCompactFunction :: SomeException -- for the RTS +cannotCompactFunction :: SomeExceptionWithLocation -- for the RTS cannotCompactFunction = toException (CompactionFailed "cannot compact functions") -cannotCompactPinned :: SomeException -- for the RTS +cannotCompactPinned :: SomeExceptionWithLocation -- for the RTS cannotCompactPinned = toException (CompactionFailed "cannot compact pinned objects") -cannotCompactMutable :: SomeException -- for the RTS +cannotCompactMutable :: SomeExceptionWithLocation -- for the RTS cannotCompactMutable = toException (CompactionFailed "cannot compact mutable objects") @@ -184,11 +184,11 @@ instance Show SomeAsyncException where instance Exception SomeAsyncException -- |@since 4.7.0.0 -asyncExceptionToException :: Exception e => e -> SomeException +asyncExceptionToException :: Exception e => e -> SomeExceptionWithLocation asyncExceptionToException = toException . SomeAsyncException -- |@since 4.7.0.0 -asyncExceptionFromException :: Exception e => SomeException -> Maybe e +asyncExceptionFromException :: Exception e => SomeExceptionWithLocation -> Maybe e asyncExceptionFromException x = do SomeAsyncException a <- fromException x cast a @@ -251,7 +251,7 @@ data ArrayException instance Exception ArrayException -- for the RTS -stackOverflow, heapOverflow :: SomeException +stackOverflow, heapOverflow :: SomeExceptionWithLocation stackOverflow = toException StackOverflow heapOverflow = toException HeapOverflow @@ -471,4 +471,3 @@ untangle coded message _ -> (loc, "") } not_bar c = c /= '|' - diff --git a/libraries/base/GHC/IO/Handle.hs b/libraries/base/GHC/IO/Handle.hs index 9bfb7df4cb..690b971c04 100644 --- a/libraries/base/GHC/IO/Handle.hs +++ b/libraries/base/GHC/IO/Handle.hs @@ -701,7 +701,7 @@ hDuplicateTo h1 _ = ioe_dupHandlesNotCompatible h1 try :: IO () -> IO () -try io = io `catchException` (const (pure ()) :: SomeException -> IO ()) +try io = io `catchException` (const (pure ()) :: SomeExceptionWithLocation -> IO ()) ioe_dupHandlesNotCompatible :: Handle -> IO a ioe_dupHandlesNotCompatible h = @@ -768,4 +768,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - diff --git a/libraries/base/GHC/IO/Handle/Internals.hs b/libraries/base/GHC/IO/Handle/Internals.hs index cbd43c1666..1edbf2badc 100644 --- a/libraries/base/GHC/IO/Handle/Internals.hs +++ b/libraries/base/GHC/IO/Handle/Internals.hs @@ -840,17 +840,17 @@ hClose_impl h@(DuplexHandle _ r w) = do excs <- mapM (hClose' h) [r,w] hClose_maybethrow (listToMaybe (catMaybes excs)) h -hClose_maybethrow :: Maybe SomeException -> Handle -> IO () +hClose_maybethrow :: Maybe SomeExceptionWithLocation -> Handle -> IO () hClose_maybethrow Nothing h = return () hClose_maybethrow (Just e) h = hClose_rethrow e h -hClose_rethrow :: SomeException -> Handle -> IO () +hClose_rethrow :: SomeExceptionWithLocation -> Handle -> IO () hClose_rethrow e h = case fromException e of Just ioe -> ioError (augmentIOError ioe "hClose" h) Nothing -> throwIO e -hClose' :: Handle -> MVar Handle__ -> IO (Maybe SomeException) +hClose' :: Handle -> MVar Handle__ -> IO (Maybe SomeExceptionWithLocation) hClose' h m = withHandle' "hClose" h m $ hClose_help -- hClose_help is also called by lazyRead (in GHC.IO.Handle.Text) when @@ -859,7 +859,7 @@ hClose' h m = withHandle' "hClose" h m $ hClose_help -- careful with DuplexHandles though: we have to leave the closing to -- the finalizer in that case, because the write side may still be in -- use. -hClose_help :: Handle__ -> IO (Handle__, Maybe SomeException) +hClose_help :: Handle__ -> IO (Handle__, Maybe SomeExceptionWithLocation) hClose_help handle_ = case haType handle_ of ClosedHandle -> return (handle_,Nothing) @@ -871,10 +871,10 @@ hClose_help handle_ = return (h_, if isJust mb_exc1 then mb_exc1 else mb_exc2) -trymaybe :: IO () -> IO (Maybe SomeException) +trymaybe :: IO () -> IO (Maybe SomeExceptionWithLocation) trymaybe io = (do io; return Nothing) `catchException` \e -> return (Just e) -hClose_handle_ :: Handle__ -> IO (Handle__, Maybe SomeException) +hClose_handle_ :: Handle__ -> IO (Handle__, Maybe SomeExceptionWithLocation) hClose_handle_ h_@Handle__{..} = do -- close the file descriptor, but not when this is the read @@ -1080,4 +1080,3 @@ decodeByteBuf h_@Handle__{..} cbuf = do writeIORef haByteBuffer bbuf2 return cbuf' - diff --git a/libraries/base/GHC/IO/Handle/Text.hs b/libraries/base/GHC/IO/Handle/Text.hs index 0e3dcd709e..33d63909ff 100644 --- a/libraries/base/GHC/IO/Handle/Text.hs +++ b/libraries/base/GHC/IO/Handle/Text.hs @@ -477,7 +477,7 @@ hGetContents' handle = do Just ioe -> throwIO (augmentIOError ioe "hGetContents'" handle) Nothing -> throwIO e -strictRead :: Handle -> Handle__ -> IO (Handle__, Either SomeException String) +strictRead :: Handle -> Handle__ -> IO (Handle__, Either SomeExceptionWithLocation String) strictRead h handle_@Handle__{..} = do cbuf <- readIORef haCharBuffer cbufs <- strictReadLoop' handle_ [] cbuf @@ -1157,4 +1157,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - diff --git a/libraries/base/GHC/IOPort.hs b/libraries/base/GHC/IOPort.hs index 46a553ca51..bc2c660f09 100644 --- a/libraries/base/GHC/IOPort.hs +++ b/libraries/base/GHC/IOPort.hs @@ -46,7 +46,7 @@ instance Exception IOPortException where displayException IOPortException = "IOPortException" -doubleReadException :: SomeException +doubleReadException :: SomeExceptionWithLocation doubleReadException = toException IOPortException data IOPort a = IOPort (IOPort# RealWorld a) @@ -119,4 +119,3 @@ writeIOPort (IOPort ioport#) x = IO $ \ s# -> case writeIOPort# ioport# x s# of (# s, 0# #) -> (# s, False #) (# s, _ #) -> (# s, True #) - diff --git a/libraries/base/GHC/TopHandler.hs b/libraries/base/GHC/TopHandler.hs index 6a4e0325a6..187442e82b 100644 --- a/libraries/base/GHC/TopHandler.hs +++ b/libraries/base/GHC/TopHandler.hs @@ -154,10 +154,10 @@ runIOFastExit main = catch main topHandlerFastExit runNonIO :: a -> IO a runNonIO a = catch (a `seq` return a) topHandler -topHandler :: SomeException -> IO a +topHandler :: SomeExceptionWithLocation -> IO a topHandler err = catch (real_handler safeExit err) topHandler -topHandlerFastExit :: SomeException -> IO a +topHandlerFastExit :: SomeExceptionWithLocation -> IO a topHandlerFastExit err = catchException (real_handler fastExit err) topHandlerFastExit @@ -165,7 +165,7 @@ topHandlerFastExit err = -- (e.g. evaluating the string passed to 'error' might generate -- another error, etc.) -- -real_handler :: (Int -> IO a) -> SomeException -> IO a +real_handler :: (Int -> IO a) -> SomeExceptionWithLocation -> IO a real_handler exit se = do flushStdHandles -- before any error output case fromException se of diff --git a/libraries/base/System/Exit.hs b/libraries/base/System/Exit.hs index e4f7b13e33..28c45d8073 100644 --- a/libraries/base/System/Exit.hs +++ b/libraries/base/System/Exit.hs @@ -47,7 +47,7 @@ import GHC.IO.Exception -- -- As an 'ExitCode' is not an 'IOError', 'exitWith' bypasses -- the error handling in the 'IO' monad and cannot be intercepted by --- 'catch' from the "Prelude". However it is a 'Control.Exception.SomeException', and can +-- 'catch' from the "Prelude". However it is a 'Control.Exception.SomeExceptionWithLocation', and can -- be caught using the functions of "Control.Exception". This means -- that cleanup computations added with 'Control.Exception.bracket' -- (from "Control.Exception") are also executed properly on 'exitWith'. diff --git a/libraries/base/System/Timeout.hs b/libraries/base/System/Timeout.hs index cfddccce3f..d13df573f2 100644 --- a/libraries/base/System/Timeout.hs +++ b/libraries/base/System/Timeout.hs @@ -92,7 +92,7 @@ instance Exception Timeout where --- -- Note that 'timeout' cancels the computation by throwing it the 'Timeout' -- exception. Consequently blanket exception handlers (e.g. catching --- 'SomeException') within the computation will break the timeout behavior. +-- 'SomeExceptionWithLocation') within the computation will break the timeout behavior. timeout :: Int -> IO a -> IO (Maybe a) timeout n f | n < 0 = fmap Just f diff --git a/libraries/base/tests/IO/T7853.hs b/libraries/base/tests/IO/T7853.hs index e46795ec9d..eed5c50cd9 100644 --- a/libraries/base/tests/IO/T7853.hs +++ b/libraries/base/tests/IO/T7853.hs @@ -4,7 +4,7 @@ import GHC.Foreign import Control.Exception import Data.Word -decode :: TextEncoding -> BS.ByteString -> IO (Either SomeException String) +decode :: TextEncoding -> BS.ByteString -> IO (Either SomeExceptionWithLocation String) decode enc bs = try $ BS.useAsCStringLen bs $ peekCStringLen enc main :: IO () diff --git a/libraries/base/tests/IO/encoding004.hs b/libraries/base/tests/IO/encoding004.hs index ffd76191f3..4cd739aa47 100644 --- a/libraries/base/tests/IO/encoding004.hs +++ b/libraries/base/tests/IO/encoding004.hs @@ -13,16 +13,16 @@ import GHC.Foreign import Control.Exception -decode :: TextEncoding -> BS.ByteString -> IO (Either SomeException String) +decode :: TextEncoding -> BS.ByteString -> IO (Either SomeExceptionWithLocation String) decode enc bs = try $ BS.useAsCStringLen bs $ peekCStringLen enc -encode :: TextEncoding -> String -> IO (Either SomeException BS.ByteString) +encode :: TextEncoding -> String -> IO (Either SomeExceptionWithLocation BS.ByteString) encode enc cs = try $ withCStringLen enc cs $ BS.packCStringLen -decodeEncode :: TextEncoding -> BS.ByteString -> IO (Either SomeException BS.ByteString) +decodeEncode :: TextEncoding -> BS.ByteString -> IO (Either SomeExceptionWithLocation BS.ByteString) decodeEncode enc bs = decode enc bs `bind` encode enc -encodedecode :: TextEncoding -> String -> IO (Either SomeException String) +encodedecode :: TextEncoding -> String -> IO (Either SomeExceptionWithLocation String) encodedecode enc bs = encode enc bs `bind` decode enc bind mx fxmy = do @@ -79,7 +79,7 @@ testTruncations enc max_byte_length bs = do Nothing -> return () Just es -> putStrLn ("Failed on consecutive truncated byte indexes " ++ show (i:js) ++ " (" ++ show (e:es) ++ ")") -testTruncation :: TextEncoding -> BS.ByteString -> IO (Maybe (Int, SomeException)) +testTruncation :: TextEncoding -> BS.ByteString -> IO (Maybe (Int, SomeExceptionWithLocation)) testTruncation enc expected = do --putStr (show i ++ ": ") >> hFlush stdout ei_e_actual <- decodeEncode enc expected diff --git a/libraries/base/tests/IO/hClose002.hs b/libraries/base/tests/IO/hClose002.hs index 20eb0f888a..8bb4a647a8 100644 --- a/libraries/base/tests/IO/hClose002.hs +++ b/libraries/base/tests/IO/hClose002.hs @@ -24,9 +24,8 @@ main = do showPossibleException :: IO () -> IO () showPossibleException f = do e <- try f - print (e :: Either SomeException ()) + print (e :: Either SomeExceptionWithLocation ()) -naughtyClose h = +naughtyClose h = withHandle_ "naughtyClose" h $ \ Handle__{haDevice=dev} -> IODevice.close dev - diff --git a/libraries/base/tests/T11555.hs b/libraries/base/tests/T11555.hs index ce5b9617c9..d360e49354 100644 --- a/libraries/base/tests/T11555.hs +++ b/libraries/base/tests/T11555.hs @@ -5,5 +5,5 @@ import Control.Exception main :: IO () main = catch (error "uh oh") handler -handler :: SomeException -> IO () +handler :: SomeExceptionWithLocation -> IO () handler _ = putStrLn "it failed" diff --git a/libraries/base/tests/T7787.hs b/libraries/base/tests/T7787.hs index 883f4a9b96..d23947c511 100644 --- a/libraries/base/tests/T7787.hs +++ b/libraries/base/tests/T7787.hs @@ -4,5 +4,5 @@ import Control.Exception main = do mv <- newMVar 'x' e <- try (modifyMVar mv $ \_ -> return undefined) - let _ = e :: Either SomeException () + let _ = e :: Either SomeExceptionWithLocation () withMVar mv print -- should not hang diff --git a/libraries/base/tests/enum01.hs b/libraries/base/tests/enum01.hs index 4dfc29978c..7b2f43d4cd 100644 --- a/libraries/base/tests/enum01.hs +++ b/libraries/base/tests/enum01.hs @@ -511,7 +511,7 @@ testEnumRatioInt = do mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) - `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeExceptionWithLocation))) test :: Show a => String -> String -> a -> IO () test test_nm expected val = do diff --git a/libraries/base/tests/enum02.hs b/libraries/base/tests/enum02.hs index 3741880f57..4e63a6e4ee 100644 --- a/libraries/base/tests/enum02.hs +++ b/libraries/base/tests/enum02.hs @@ -26,7 +26,7 @@ testEnumInt8 = do -- pred printTest (pred (1::Int8)) printTest (pred (maxBound::Int8)) - mayBomb (printTest (pred (minBound::Int8))) + mayBomb (printTest (pred (minBound::Int8))) -- toEnum printTest ((map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)])) @@ -38,7 +38,7 @@ testEnumInt8 = do -- [x..] aka enumFrom printTest ((take 7 [(1::Int8)..])) printTest ((take 7 [((maxBound::Int8)-5)..])) -- just in case it doesn't catch the upper bound.. - + -- [x,y..] aka enumFromThen printTest ((take 7 [(1::Int8),2..])) printTest ((take 7 [(1::Int8),7..])) @@ -84,7 +84,7 @@ testEnumInt16 = do -- pred printTest (pred (1::Int16)) printTest (pred (maxBound::Int16)) - mayBomb (printTest (pred (minBound::Int16))) + mayBomb (printTest (pred (minBound::Int16))) -- toEnum printTest ((map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)])) @@ -97,7 +97,7 @@ testEnumInt16 = do -- [x..] aka enumFrom printTest ((take 7 [(1::Int16)..])) printTest ((take 7 [((maxBound::Int16)-5)..])) -- just in case it doesn't catch the upper bound.. - + -- [x,y..] aka enumFromThen printTest ((take 7 [(1::Int16),2..])) printTest ((take 7 [(1::Int16),7..])) @@ -143,7 +143,7 @@ testEnumInt32 = do -- pred printTest (pred (1::Int32)) printTest (pred (maxBound::Int32)) - mayBomb (printTest (pred (minBound::Int32))) + mayBomb (printTest (pred (minBound::Int32))) -- toEnum printTest ((map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)])) @@ -155,7 +155,7 @@ testEnumInt32 = do -- [x..] aka enumFrom printTest ((take 7 [(1::Int32)..])) printTest ((take 7 [((maxBound::Int32)-5)..])) -- just in case it doesn't catch the upper bound.. - + -- [x,y..] aka enumFromThen printTest ((take 7 [(1::Int32),2..])) printTest ((take 7 [(1::Int32),7..])) @@ -201,7 +201,7 @@ testEnumInt64 = do -- pred printTest (pred (1::Int64)) printTest (pred (maxBound::Int64)) - mayBomb (printTest (pred (minBound::Int64))) + mayBomb (printTest (pred (minBound::Int64))) -- toEnum mayBomb (printTest ((map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]))) @@ -259,4 +259,4 @@ testEnumInt64 = do mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) - `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeExceptionWithLocation))) diff --git a/libraries/base/tests/enum03.hs b/libraries/base/tests/enum03.hs index a701df4501..4193ab76d0 100644 --- a/libraries/base/tests/enum03.hs +++ b/libraries/base/tests/enum03.hs @@ -28,7 +28,7 @@ testEnumWord8 = do -- pred printTest (pred (1::Word8)) printTest (pred (maxBound::Word8)) - mayBomb (printTest (pred (minBound::Word8))) + mayBomb (printTest (pred (minBound::Word8))) -- toEnum printTest ((map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int])) @@ -86,7 +86,7 @@ testEnumWord16 = do -- pred printTest (pred (1::Word16)) printTest (pred (maxBound::Word16)) - mayBomb (printTest (pred (minBound::Word16))) + mayBomb (printTest (pred (minBound::Word16))) -- toEnum printTest ((map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int])) @@ -99,7 +99,7 @@ testEnumWord16 = do -- [x..] aka enumFrom printTest ((take 7 [(1::Word16)..])) printTest ((take 7 [((maxBound::Word16)-5)..])) -- just in case it doesn't catch the upper bound.. - + -- [x,y..] aka enumFromThen printTest ((take 7 [(1::Word16),2..])) printTest ((take 7 [(1::Word16),7..])) @@ -145,7 +145,7 @@ testEnumWord32 = do -- pred printTest (pred (1::Word32)) printTest (pred (maxBound::Word32)) - mayBomb (printTest (pred (minBound::Word32))) + mayBomb (printTest (pred (minBound::Word32))) -- toEnum printTest ((map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int])) @@ -158,7 +158,7 @@ testEnumWord32 = do -- [x..] aka enumFrom printTest ((take 7 [(1::Word32)..])) printTest ((take 7 [((maxBound::Word32)-5)..])) -- just in case it doesn't catch the upper bound.. - + -- [x,y..] aka enumFromThen printTest ((take 7 [(1::Word32),2..])) printTest ((take 7 [(1::Word32),7..])) @@ -204,7 +204,7 @@ testEnumWord64 = do -- pred printTest (pred (1::Word64)) printTest (pred (maxBound::Word64)) - mayBomb (printTest (pred (minBound::Word64))) + mayBomb (printTest (pred (minBound::Word64))) -- toEnum mayBomb (printTest ((map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]))) @@ -262,4 +262,4 @@ testEnumWord64 = do mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) - `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeExceptionWithLocation))) diff --git a/libraries/base/tests/enum04.hs b/libraries/base/tests/enum04.hs index a96d747057..80360e90fc 100644 --- a/libraries/base/tests/enum04.hs +++ b/libraries/base/tests/enum04.hs @@ -8,7 +8,7 @@ import Control.Exception -- Float and Double). main = do - catch (evaluate [error "" :: Int ..] >> return ()) (\(e::SomeException) -> putStrLn "ok1") - catch (evaluate [error "" :: Integer ..] >> return ()) (\(e::SomeException) -> putStrLn "ok2") - catch (evaluate [error "" :: Float ..] >> return ()) (\(e::SomeException) -> putStrLn "ok3") - catch (evaluate [error "" :: Double ..] >> return ()) (\(e::SomeException) -> putStrLn "ok4") + catch (evaluate [error "" :: Int ..] >> return ()) (\(e::SomeExceptionWithLocation) -> putStrLn "ok1") + catch (evaluate [error "" :: Integer ..] >> return ()) (\(e::SomeExceptionWithLocation) -> putStrLn "ok2") + catch (evaluate [error "" :: Float ..] >> return ()) (\(e::SomeExceptionWithLocation) -> putStrLn "ok3") + catch (evaluate [error "" :: Double ..] >> return ()) (\(e::SomeExceptionWithLocation) -> putStrLn "ok4") diff --git a/libraries/base/tests/exceptionsrun002.hs b/libraries/base/tests/exceptionsrun002.hs index 0dae46117d..da55ebc254 100644 --- a/libraries/base/tests/exceptionsrun002.hs +++ b/libraries/base/tests/exceptionsrun002.hs @@ -6,7 +6,7 @@ import Data.IORef safeCatch :: IO () -> IO () safeCatch f = Exception.catch f - ((\_ -> return ()) :: Exception.SomeException -> IO ()) + ((\_ -> return ()) :: Exception.SomeExceptionWithLocation -> IO ()) type Thrower = IO Bool @@ -82,7 +82,7 @@ preludeCatchCatcher = MkNamed "Prelude.catch" ceCatchCatcher :: Named Catcher ceCatchCatcher = MkNamed "Exception.catch" - (\f cc -> Exception.catch (f >> (return ())) (const cc :: Exception.SomeException -> IO ())) + (\f cc -> Exception.catch (f >> (return ())) (const cc :: Exception.SomeExceptionWithLocation -> IO ())) finallyCatcher :: Named Catcher finallyCatcher = MkNamed "Exception.finally" @@ -92,4 +92,3 @@ main = checkNamedCatches [bindCatcher,preludeCatchCatcher,ceCatchCatcher,finallyCatcher] [returnThrower,returnUndefinedThrower,returnThrowThrower,returnErrorThrower,failThrower, errorThrower,throwThrower,ioErrorErrorCallThrower,ioErrorIOExceptionThrower,undefinedThrower] - diff --git a/libraries/base/tests/quotOverflow.hs b/libraries/base/tests/quotOverflow.hs index 8d958f8869..eb21dfc5ff 100644 --- a/libraries/base/tests/quotOverflow.hs +++ b/libraries/base/tests/quotOverflow.hs @@ -29,5 +29,4 @@ f = sequence [ g (minBound `div` (-1)), where g x = do x' <- evaluate x return (Left x') `E.catch` - \e -> return (Right (show (e :: SomeException))) - + \e -> return (Right (show (e :: SomeExceptionWithLocation))) diff --git a/libraries/directory b/libraries/directory -Subproject adb8b4d67356c4eca92f62fd1b7c1ac8add4241 +Subproject ff2c33a4827f530e797d04f09177dabf5a5789d diff --git a/libraries/exceptions b/libraries/exceptions -Subproject ebc21bd7efc858571935440dc9c4178d448448c +Subproject 247af559f77d1e6a7768ebace6c24689b938e5d diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index 6b23f913cb..f114cefd7e 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -54,6 +54,10 @@ import System.Exit import System.IO import System.IO.Error +#if __GLASGOW_HASKELL__ < 903 +type SomeExceptionWithLocation = SomeException +#endif + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server @@ -394,7 +398,7 @@ data EvalResult a instance Binary a => Binary (EvalResult a) --- SomeException can't be serialized because it contains dynamic +-- SomeExceptionWithLocation can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: -- @@ -411,13 +415,13 @@ data SerializableException | EOtherException String deriving (Generic, Show) -toSerializableException :: SomeException -> SerializableException +toSerializableException :: SomeExceptionWithLocation -> SerializableException toSerializableException ex | Just UserInterrupt <- fromException ex = EUserInterrupt | Just (ec::ExitCode) <- fromException ex = (EExitCode ec) - | otherwise = EOtherException (show (ex :: SomeException)) + | otherwise = EOtherException (show (ex :: SomeExceptionWithLocation)) -fromSerializableException :: SerializableException -> SomeException +fromSerializableException :: SerializableException -> SomeExceptionWithLocation fromSerializableException EUserInterrupt = toException UserInterrupt fromSerializableException (EExitCode c) = toException c fromSerializableException (EOtherException str) = toException (ErrorCall str) diff --git a/libraries/ghci/GHCi/Run.hs b/libraries/ghci/GHCi/Run.hs index 4ecb64620a..ad062672e0 100644 --- a/libraries/ghci/GHCi/Run.hs +++ b/libraries/ghci/GHCi/Run.hs @@ -246,7 +246,7 @@ redirectInterrupts target wait = do m <- deRefWeak wtid case m of Nothing -> wait - Just target -> do throwTo target (e :: SomeException); wait + Just target -> do throwTo target (e :: SomeExceptionWithLocation); wait measureAlloc :: IO (EvalResult a) -> IO (EvalStatus a) measureAlloc io = do diff --git a/libraries/haskeline b/libraries/haskeline -Subproject 2a5d9451ab7a0602b604a4bf0b9f950e913b865 +Subproject dfc99907039482683e01894300afb33431476f0 diff --git a/libraries/libiserv/src/IServ.hs b/libraries/libiserv/src/IServ.hs index 6361a8c04c..db2044e1fc 100644 --- a/libraries/libiserv/src/IServ.hs +++ b/libraries/libiserv/src/IServ.hs @@ -66,10 +66,10 @@ serv verbose hook pipe restore = loop -- carefully when showing an exception, there might be other exceptions -- lurking inside it. If so, we return the inner exception instead. - showException :: SomeException -> IO String + showException :: SomeExceptionWithLocation -> IO String showException e0 = do when verbose $ trace "showException" - r <- try $ evaluate (force (show (e0::SomeException))) + r <- try $ evaluate (force (show (e0::SomeExceptionWithLocation))) case r of Left e -> showException e Right str -> return str diff --git a/libraries/process b/libraries/process -Subproject 7fd28338c82c89deb3e5db117e87633898046d7 +Subproject bcbbb902b5f6f9bbd433873b6ce097594ea8c75 diff --git a/libraries/stm b/libraries/stm -Subproject a58fdfadbcfd2743944e6a3c4bc734cfbca8913 +Subproject 3fbd061e76a76cf0ae5ccc66b29c14cdfc7dbc5 diff --git a/libraries/unix b/libraries/unix -Subproject 1f72ccec55c1b61299310b994754782103a617f +Subproject c7a95042a77244756f5b6476bf7dcf7190bc9e3 diff --git a/testsuite/tests/codeGen/should_run/cgrun025.hs b/testsuite/tests/codeGen/should_run/cgrun025.hs index 39255c147d..522116b3a6 100644 --- a/testsuite/tests/codeGen/should_run/cgrun025.hs +++ b/testsuite/tests/codeGen/should_run/cgrun025.hs @@ -22,4 +22,4 @@ main = do file_cts <- readFile (head args) hPutStr stderr file_cts trace "hello, trace" $ - catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeException) -> error "hello, error") + catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeExceptionWithLocation) -> error "hello, error") diff --git a/testsuite/tests/codeGen/should_run/cgrun025.stderr b/testsuite/tests/codeGen/should_run/cgrun025.stderr index 35ad64c79c..cf09b76c2b 100644 --- a/testsuite/tests/codeGen/should_run/cgrun025.stderr +++ b/testsuite/tests/codeGen/should_run/cgrun025.stderr @@ -25,7 +25,7 @@ main = do file_cts <- readFile (head args) hPutStr stderr file_cts trace "hello, trace" $ - catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeException) -> error "hello, error") + catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeExceptionWithLocation) -> error "hello, error") hello, trace cgrun025: hello, error CallStack (from HasCallStack): diff --git a/testsuite/tests/codeGen/should_run/cgrun057.hs b/testsuite/tests/codeGen/should_run/cgrun057.hs index 98f90db15a..ea4636d169 100644 --- a/testsuite/tests/codeGen/should_run/cgrun057.hs +++ b/testsuite/tests/codeGen/should_run/cgrun057.hs @@ -1,6 +1,6 @@ -- For testing +RTS -xc import Control.Exception -main = try (evaluate (f ())) :: IO (Either SomeException ()) +main = try (evaluate (f ())) :: IO (Either SomeExceptionWithLocation ()) f x = g x diff --git a/testsuite/tests/concurrent/should_run/T3279.hs b/testsuite/tests/concurrent/should_run/T3279.hs index b721a6113c..a5ac0d7497 100644 --- a/testsuite/tests/concurrent/should_run/T3279.hs +++ b/testsuite/tests/concurrent/should_run/T3279.hs @@ -7,14 +7,14 @@ import GHC.IO (unsafeUnmask) f :: Int f = (1 +) . unsafePerformIO $ do - throwIO (ErrorCall "foo") `catch` \(SomeException e) -> do + throwIO (ErrorCall "foo") `catch` \(SomeExceptionWithLocation e) -> do myThreadId >>= flip throwTo e -- point X unsafeUnmask $ return 1 main :: IO () main = do - evaluate f `catch` \(SomeException e) -> return 0 + evaluate f `catch` \(SomeExceptionWithLocation e) -> return 0 -- the evaluation of 'x' is now suspended at point X tid <- mask_ $ forkIO (evaluate f >> return ()) killThread tid @@ -22,4 +22,3 @@ main = do yield -- should print 1 + 1 = 2 print f - diff --git a/testsuite/tests/concurrent/should_run/T5238.hs b/testsuite/tests/concurrent/should_run/T5238.hs index 1de60c4e80..5f85753db2 100644 --- a/testsuite/tests/concurrent/should_run/T5238.hs +++ b/testsuite/tests/concurrent/should_run/T5238.hs @@ -7,6 +7,6 @@ import GHC.Conc main = do ms1 ← getMaskingState atomically $ (throwSTM Overflow) `catchSTM` - (\(e ∷ SomeException) → return ()) + (\(e ∷ SomeExceptionWithLocation) → return ()) ms2 ← getMaskingState putStrLn $ show (ms1, ms2) diff --git a/testsuite/tests/concurrent/should_run/T7970.hs b/testsuite/tests/concurrent/should_run/T7970.hs index 986cb66b27..003ae4da06 100644 --- a/testsuite/tests/concurrent/should_run/T7970.hs +++ b/testsuite/tests/concurrent/should_run/T7970.hs @@ -15,6 +15,6 @@ main = do m <- newEmptyMVar check takeMVar m `catch` \ex -> do - putStrLn $ "caught exception: " ++ show (ex :: SomeException) + putStrLn $ "caught exception: " ++ show (ex :: SomeExceptionWithLocation) check readIORef ref >>= print diff --git a/testsuite/tests/concurrent/should_run/allocLimit3.hs b/testsuite/tests/concurrent/should_run/allocLimit3.hs index 28881dc016..bdebf3cde1 100644 --- a/testsuite/tests/concurrent/should_run/allocLimit3.hs +++ b/testsuite/tests/concurrent/should_run/allocLimit3.hs @@ -12,4 +12,4 @@ main = do -- result, and then immediately raise the exception r <- mask_ $ try $ print (length [1..100000]) - print (r :: Either SomeException ()) + print (r :: Either SomeExceptionWithLocation ()) diff --git a/testsuite/tests/concurrent/should_run/async001.hs b/testsuite/tests/concurrent/should_run/async001.hs index 7d765e26f9..777ecf92c3 100644 --- a/testsuite/tests/concurrent/should_run/async001.hs +++ b/testsuite/tests/concurrent/should_run/async001.hs @@ -8,7 +8,7 @@ import System.IO.Unsafe -- 'onException'. main = do - let x = unsafePerformIO $ + let x = unsafePerformIO $ (do threadDelay 1000000; return 42) `onException` return () @@ -16,4 +16,4 @@ main = do threadDelay 1000 killThread t - print x `E.catch` \e -> putStrLn ("main caught: " ++ show (e::SomeException)) + print x `E.catch` \e -> putStrLn ("main caught: " ++ show (e::SomeExceptionWithLocation)) diff --git a/testsuite/tests/concurrent/should_run/conc008.hs b/testsuite/tests/concurrent/should_run/conc008.hs index 66a4b5f973..6bdc14508d 100644 --- a/testsuite/tests/concurrent/should_run/conc008.hs +++ b/testsuite/tests/concurrent/should_run/conc008.hs @@ -6,7 +6,7 @@ import Control.Exception -- Send ourselves a KillThread signal, catch it and recover. -main = do +main = do id <- myThreadId Control.Exception.catch (killThread id) $ - \e -> putStr (show (e::SomeException)) + \e -> putStr (show (e::SomeExceptionWithLocation)) diff --git a/testsuite/tests/concurrent/should_run/conc010.hs b/testsuite/tests/concurrent/should_run/conc010.hs index 21ced56f5a..1b037dc4d6 100644 --- a/testsuite/tests/concurrent/should_run/conc010.hs +++ b/testsuite/tests/concurrent/should_run/conc010.hs @@ -22,7 +22,7 @@ main = do ready <- newEmptyMVar ready2 <- newEmptyMVar id <- forkIO (Control.Exception.catch (putMVar ready () >> takeMVar block) - (\e -> putStr (show (e::SomeException)) >> putMVar ready2 ())) + (\e -> putStr (show (e::SomeExceptionWithLocation)) >> putMVar ready2 ())) takeMVar ready throwTo id (ErrorCall "hello") takeMVar ready2 diff --git a/testsuite/tests/concurrent/should_run/conc012.hs b/testsuite/tests/concurrent/should_run/conc012.hs index 9a94351ed6..e41744e49f 100644 --- a/testsuite/tests/concurrent/should_run/conc012.hs +++ b/testsuite/tests/concurrent/should_run/conc012.hs @@ -4,7 +4,7 @@ import Control.Concurrent import Control.Exception --import GlaExts -data Result = Died SomeException | Finished +data Result = Died SomeExceptionWithLocation | Finished -- Test stack overflow catching. Should print "Died: stack overflow". diff --git a/testsuite/tests/concurrent/should_run/conc014.hs b/testsuite/tests/concurrent/should_run/conc014.hs index 8078f9907c..23c464ccc9 100644 --- a/testsuite/tests/concurrent/should_run/conc014.hs +++ b/testsuite/tests/concurrent/should_run/conc014.hs @@ -14,7 +14,7 @@ main = do do putMVar m (); evaluate (sum [1..10000]); putStrLn "done.") ; myDelay 500000 }) `Control.Exception.catch` - \e -> putStrLn ("caught: " ++ show (e::SomeException)) + \e -> putStrLn ("caught: " ++ show (e::SomeExceptionWithLocation)) -- compensate for the fact that threadDelay is non-interruptible -- on Windows with the threaded RTS in 6.6. @@ -22,4 +22,3 @@ myDelay usec = do m <- newEmptyMVar forkIO $ do threadDelay usec; putMVar m () takeMVar m - diff --git a/testsuite/tests/concurrent/should_run/conc015.hs b/testsuite/tests/concurrent/should_run/conc015.hs index e7215097ca..8c102fa0c8 100644 --- a/testsuite/tests/concurrent/should_run/conc015.hs +++ b/testsuite/tests/concurrent/should_run/conc015.hs @@ -27,13 +27,13 @@ main = do sum [1..1] `seq` -- give 'foo' a chance to be raised (restore $ myDelay 500000) `Control.Exception.catch` - \e -> putStrLn ("caught1: " ++ show (e::SomeException)) + \e -> putStrLn ("caught1: " ++ show (e::SomeExceptionWithLocation)) threadDelay 10000 takeMVar m2 ) `Control.Exception.catch` \e -> do print =<< getMaskingState - putStrLn ("caught2: " ++ show (e::SomeException)) + putStrLn ("caught2: " ++ show (e::SomeExceptionWithLocation)) -- compensate for the fact that threadDelay is non-interruptible -- on Windows with the threaded RTS in 6.6. diff --git a/testsuite/tests/concurrent/should_run/conc015a.hs b/testsuite/tests/concurrent/should_run/conc015a.hs index a6a55c12cd..641a7fbc0c 100644 --- a/testsuite/tests/concurrent/should_run/conc015a.hs +++ b/testsuite/tests/concurrent/should_run/conc015a.hs @@ -30,14 +30,14 @@ main = do sum [1..100000] `seq` -- give 'foo' a chance to be raised (restore (myDelay 500000) `Control.Exception.catch` - \e -> putStrLn ("caught1: " ++ show (e::SomeException))) + \e -> putStrLn ("caught1: " ++ show (e::SomeExceptionWithLocation))) threadDelay 10000 takeMVar m2 ) `Control.Exception.catch` \e -> do print =<< getMaskingState - putStrLn ("caught2: " ++ show (e::SomeException)) + putStrLn ("caught2: " ++ show (e::SomeExceptionWithLocation)) -- compensate for the fact that threadDelay is non-interruptible -- on Windows with the threaded RTS in 6.6. diff --git a/testsuite/tests/concurrent/should_run/conc017.hs b/testsuite/tests/concurrent/should_run/conc017.hs index 69c171732e..f80531633f 100644 --- a/testsuite/tests/concurrent/should_run/conc017.hs +++ b/testsuite/tests/concurrent/should_run/conc017.hs @@ -24,17 +24,17 @@ main = do myDelay 100000 ) ) `Control.Exception.catch` - \e -> putStrLn ("caught1: " ++ show (e::SomeException)) + \e -> putStrLn ("caught1: " ++ show (e::SomeExceptionWithLocation)) putMVar m2 () -- blocked here, "bar" can't be delivered (sum [1..10000] `seq` return ()) `Control.Exception.catch` - \e -> putStrLn ("caught2: " ++ show (e::SomeException)) + \e -> putStrLn ("caught2: " ++ show (e::SomeExceptionWithLocation)) -- unblocked here, "bar" delivered to "caught3" takeMVar m3 ) `Control.Exception.catch` - \e -> putStrLn ("caught3: " ++ show (e::SomeException)) + \e -> putStrLn ("caught3: " ++ show (e::SomeExceptionWithLocation)) -- compensate for the fact that threadDelay is non-interruptible -- on Windows with the threaded RTS in 6.6. diff --git a/testsuite/tests/concurrent/should_run/conc017a.hs b/testsuite/tests/concurrent/should_run/conc017a.hs index 69c171732e..f80531633f 100644 --- a/testsuite/tests/concurrent/should_run/conc017a.hs +++ b/testsuite/tests/concurrent/should_run/conc017a.hs @@ -24,17 +24,17 @@ main = do myDelay 100000 ) ) `Control.Exception.catch` - \e -> putStrLn ("caught1: " ++ show (e::SomeException)) + \e -> putStrLn ("caught1: " ++ show (e::SomeExceptionWithLocation)) putMVar m2 () -- blocked here, "bar" can't be delivered (sum [1..10000] `seq` return ()) `Control.Exception.catch` - \e -> putStrLn ("caught2: " ++ show (e::SomeException)) + \e -> putStrLn ("caught2: " ++ show (e::SomeExceptionWithLocation)) -- unblocked here, "bar" delivered to "caught3" takeMVar m3 ) `Control.Exception.catch` - \e -> putStrLn ("caught3: " ++ show (e::SomeException)) + \e -> putStrLn ("caught3: " ++ show (e::SomeExceptionWithLocation)) -- compensate for the fact that threadDelay is non-interruptible -- on Windows with the threaded RTS in 6.6. diff --git a/testsuite/tests/concurrent/should_run/conc018.hs b/testsuite/tests/concurrent/should_run/conc018.hs index 7caf32613e..ea89a8f30f 100644 --- a/testsuite/tests/concurrent/should_run/conc018.hs +++ b/testsuite/tests/concurrent/should_run/conc018.hs @@ -21,6 +21,6 @@ main = do m <- newMVar () putMVar m () ) - (\e -> putMVar m (e::SomeException)) + (\e -> putMVar m (e::SomeExceptionWithLocation)) takeMVar m >>= print -- should print "thread blocked indefinitely" diff --git a/testsuite/tests/concurrent/should_run/conc019.hs b/testsuite/tests/concurrent/should_run/conc019.hs index 9804657aab..b514ce2675 100644 --- a/testsuite/tests/concurrent/should_run/conc019.hs +++ b/testsuite/tests/concurrent/should_run/conc019.hs @@ -7,7 +7,7 @@ import System.Mem main = do forkIO (Control.Exception.catch (do { m <- newEmptyMVar; takeMVar m }) - $ \e -> putStrLn ("caught: " ++ show (e::SomeException))) + $ \e -> putStrLn ("caught: " ++ show (e::SomeExceptionWithLocation))) threadDelay 10000 System.Mem.performGC threadDelay 10000 diff --git a/testsuite/tests/concurrent/should_run/conc024.hs b/testsuite/tests/concurrent/should_run/conc024.hs index 7d8662ae08..e7f9b38033 100644 --- a/testsuite/tests/concurrent/should_run/conc024.hs +++ b/testsuite/tests/concurrent/should_run/conc024.hs @@ -10,6 +10,6 @@ import System.Mem main = do id <- myThreadId forkIO (catch (do m <- newEmptyMVar; takeMVar m) - (\e -> throwTo id (e::SomeException))) + (\e -> throwTo id (e::SomeExceptionWithLocation))) catch (do yield; performGC; threadDelay 1000000) - (\e -> print (e::SomeException)) + (\e -> print (e::SomeExceptionWithLocation)) diff --git a/testsuite/tests/concurrent/should_run/conc033.hs b/testsuite/tests/concurrent/should_run/conc033.hs index 47c46d366f..06e78ddbff 100644 --- a/testsuite/tests/concurrent/should_run/conc033.hs +++ b/testsuite/tests/concurrent/should_run/conc033.hs @@ -7,4 +7,4 @@ main = do m <- newEmptyMVar takeMVar m return () - print (r::Either SomeException ()) + print (r::Either SomeExceptionWithLocation ()) diff --git a/testsuite/tests/concurrent/should_run/conc035.hs b/testsuite/tests/concurrent/should_run/conc035.hs index 328b0f3307..e78794bf08 100644 --- a/testsuite/tests/concurrent/should_run/conc035.hs +++ b/testsuite/tests/concurrent/should_run/conc035.hs @@ -13,7 +13,7 @@ trapHandler inVar caughtVar = `E.catch` (trapExc inVar caughtVar) -trapExc :: MVar Int -> MVar () -> E.SomeException -> IO () +trapExc :: MVar Int -> MVar () -> E.SomeExceptionWithLocation -> IO () -- If we have been killed then we are done trapExc inVar caughtVar e | Just E.ThreadKilled <- E.fromException e = return () diff --git a/testsuite/tests/concurrent/should_run/conc073.hs b/testsuite/tests/concurrent/should_run/conc073.hs index 64d9d998a6..5957334add 100644 --- a/testsuite/tests/concurrent/should_run/conc073.hs +++ b/testsuite/tests/concurrent/should_run/conc073.hs @@ -8,7 +8,7 @@ main = do mask_ $ return () throwIO (ErrorCall "test") `catch` \e -> do - let _ = e::SomeException + let _ = e::SomeExceptionWithLocation print =<< getMaskingState putMVar m1 () takeMVar m2 diff --git a/testsuite/tests/concurrent/should_run/mask002.hs b/testsuite/tests/concurrent/should_run/mask002.hs index 069af8f2fc..b8d3012927 100644 --- a/testsuite/tests/concurrent/should_run/mask002.hs +++ b/testsuite/tests/concurrent/should_run/mask002.hs @@ -9,12 +9,12 @@ main = do m <- newEmptyMVar t1 <- mask_ $ forkIO $ do takeMVar m `catch` \e -> do stat 1 MaskedInterruptible - print (e::SomeException) + print (e::SomeExceptionWithLocation) throwIO e killThread t1 t2 <- uninterruptibleMask_ $ forkIO $ do takeMVar m `catch` \e -> do stat 2 MaskedUninterruptible - print (e::SomeException) + print (e::SomeExceptionWithLocation) throwIO e killThread t2 t3 <- mask_ $ forkIOWithUnmask $ \unmask -> @@ -25,9 +25,8 @@ main = do takeMVar m stat :: Int -> MaskingState -> IO () -stat n m = do +stat n m = do s <- getMaskingState - if (s /= m) + if (s /= m) then error (printf "%2d: %s\n" n (show s)) else return () - diff --git a/testsuite/tests/concurrent/should_run/throwto002.hs b/testsuite/tests/concurrent/should_run/throwto002.hs index eaaae0c0cb..cf6b0d0e30 100644 --- a/testsuite/tests/concurrent/should_run/throwto002.hs +++ b/testsuite/tests/concurrent/should_run/throwto002.hs @@ -20,4 +20,4 @@ thread restore r t = run run = (restore $ forever $ do killThread t i <- atomicModifyIORef r (\i -> (i + 1, i)) evaluate i) - `catch` \(e::SomeException) -> run + `catch` \(e::SomeExceptionWithLocation) -> run diff --git a/testsuite/tests/concurrent/should_run/throwto003.hs b/testsuite/tests/concurrent/should_run/throwto003.hs index 37540cc68a..500a6fb329 100644 --- a/testsuite/tests/concurrent/should_run/throwto003.hs +++ b/testsuite/tests/concurrent/should_run/throwto003.hs @@ -11,6 +11,6 @@ main = do takeMVar m thread restore m = run - where + where run = (restore $ forever $ modifyMVar_ m $ \v -> if v `mod` 2 == 1 then return (v*2) else return (v-1)) - `catch` \(e::SomeException) -> run + `catch` \(e::SomeExceptionWithLocation) -> run diff --git a/testsuite/tests/deSugar/should_run/T246.hs b/testsuite/tests/deSugar/should_run/T246.hs index 2845db3ab0..f791cdb3c0 100644 --- a/testsuite/tests/deSugar/should_run/T246.hs +++ b/testsuite/tests/deSugar/should_run/T246.hs @@ -21,5 +21,5 @@ main = do { print (f funny) -- Should work, because we test ; Control.Exception.catch (print (g funny)) -- Should fail, because we test - (\(_::SomeException) -> print "caught") -- x first, and hit "undefined" + (\(_::SomeExceptionWithLocation) -> print "caught") -- x first, and hit "undefined" } diff --git a/testsuite/tests/dependent/should_compile/dynamic-paper.hs b/testsuite/tests/dependent/should_compile/dynamic-paper.hs index eaba011625..41ff423f0a 100644 --- a/testsuite/tests/dependent/should_compile/dynamic-paper.hs +++ b/testsuite/tests/dependent/should_compile/dynamic-paper.hs @@ -268,10 +268,10 @@ delta ra x = case (eqT ra rt) of Nothing -> x loop = delta rt (MkT delta) -throw# :: SomeException -> a +throw# :: SomeExceptionWithLocation -> a -data SomeException where - SomeException :: Exception e => e -> SomeException +data SomeExceptionWithLocation where + SomeExceptionWithLocation :: Exception e => e -> SomeExceptionWithLocation class (Typeable e, Show e) => Exception e where { } diff --git a/testsuite/tests/ffi/should_run/IncallAffinity.hs b/testsuite/tests/ffi/should_run/IncallAffinity.hs index 386e9950e8..9b271e83c0 100644 --- a/testsuite/tests/ffi/should_run/IncallAffinity.hs +++ b/testsuite/tests/ffi/should_run/IncallAffinity.hs @@ -11,7 +11,7 @@ foreign export ccall "capTest" capTest :: IO Int capTest :: IO Int capTest = catch go handle where - handle :: SomeException -> IO Int + handle :: SomeExceptionWithLocation -> IO Int handle e = do putStrLn $ "Failed " ++ (show e) return (-1) diff --git a/testsuite/tests/ghc-api/T8628.hs b/testsuite/tests/ghc-api/T8628.hs index 3874d6ed68..c328dac77f 100644 --- a/testsuite/tests/ghc-api/T8628.hs +++ b/testsuite/tests/ghc-api/T8628.hs @@ -26,7 +26,7 @@ main , IIDecl (simpleImportDecl (mkModuleNameFS (fsLit "System.IO")))] runDecls "data X = Y ()" execStmt "print True" execOptions - MC.try $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeException ExecResult) + MC.try $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeExceptionWithLocation ExecResult) runDecls "data X = Y () deriving Show" _ <- dynCompileExpr "'x'" execStmt "print (Y ())" execOptions diff --git a/testsuite/tests/ghci.debugger/scripts/T8487.hs b/testsuite/tests/ghci.debugger/scripts/T8487.hs index d77738e3c9..7a277b1f9b 100644 --- a/testsuite/tests/ghci.debugger/scripts/T8487.hs +++ b/testsuite/tests/ghci.debugger/scripts/T8487.hs @@ -4,7 +4,7 @@ f = do ma <- try $ evaluate a x <- case ma of Right str -> return a - Left err -> return $ show (err :: SomeException) + Left err -> return $ show (err :: SomeExceptionWithLocation) putStrLn x where a :: String diff --git a/testsuite/tests/ghci.debugger/scripts/T8487.stdout b/testsuite/tests/ghci.debugger/scripts/T8487.stdout index ab7151a563..1bdd8d5740 100644 --- a/testsuite/tests/ghci.debugger/scripts/T8487.stdout +++ b/testsuite/tests/ghci.debugger/scripts/T8487.stdout @@ -1,4 +1,4 @@ -Breakpoint 0 activated at T8487.hs:(5,8)-(7,53) -Stopped in Main.f, T8487.hs:(5,8)-(7,53) +Breakpoint 0 activated at T8487.hs:(5,8)-(7,65) +Stopped in Main.f, T8487.hs:(5,8)-(7,65) _result :: IO String = _ -ma :: Either SomeException String = Left _ +ma :: Either SomeExceptionWithLocation String = Left _ diff --git a/testsuite/tests/ghci.debugger/scripts/break011.stdout b/testsuite/tests/ghci.debugger/scripts/break011.stdout index 47fb7b135d..93e6a8e3ec 100644 --- a/testsuite/tests/ghci.debugger/scripts/break011.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break011.stdout @@ -18,28 +18,28 @@ _result :: a Stopped at <unknown> _exception :: e already at the beginning of the history -_exception = SomeException +_exception = SomeExceptionWithLocation (ErrorCallWithLocation "foo" "CallStack (from HasCallStack): error, called at Test7.hs:2:18 in main:Main") _result :: a = _ -_exception :: SomeException = SomeException - (ErrorCallWithLocation - "foo" - "CallStack (from HasCallStack): +_exception :: SomeExceptionWithLocation = SomeExceptionWithLocation + (ErrorCallWithLocation + "foo" + "CallStack (from HasCallStack): error, called at Test7.hs:2:18 in main:Main") *** Exception: foo CallStack (from HasCallStack): error, called at Test7.hs:2:18 in main:Main Stopped in <exception thrown>, <unknown> -_exception :: e = SomeException +_exception :: e = SomeExceptionWithLocation (ErrorCallWithLocation "foo" "CallStack (from HasCallStack): error, called at Test7.hs:2:18 in main:Main") Stopped in <exception thrown>, <unknown> -_exception :: e = SomeException +_exception :: e = SomeExceptionWithLocation (ErrorCallWithLocation "foo" "CallStack (from HasCallStack): diff --git a/testsuite/tests/ghci.debugger/scripts/break024.stdout b/testsuite/tests/ghci.debugger/scripts/break024.stdout index 8c09cb5533..211b1cf348 100644 --- a/testsuite/tests/ghci.debugger/scripts/break024.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break024.stdout @@ -1,21 +1,21 @@ Left user error (error) Stopped in <exception thrown>, <unknown> _exception :: e = _ -_exception = SomeException +_exception = SomeExceptionWithLocation (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError [] "error" Nothing Nothing) *** Exception: user error (error) Stopped in <exception thrown>, <unknown> _exception :: e = _ -_exception = SomeException +_exception = SomeExceptionWithLocation (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError [] "error" Nothing Nothing) Stopped in <exception thrown>, <unknown> -_exception :: e = SomeException +_exception :: e = SomeExceptionWithLocation (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError ....) Stopped in <exception thrown>, <unknown> _exception :: e = _ -_exception = SomeException +_exception = SomeExceptionWithLocation (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError [] "error" Nothing Nothing) Left user error (error) diff --git a/testsuite/tests/ghci/should_run/T19628.hs b/testsuite/tests/ghci/should_run/T19628.hs index 74891c690f..db04211903 100644 --- a/testsuite/tests/ghci/should_run/T19628.hs +++ b/testsuite/tests/ghci/should_run/T19628.hs @@ -63,7 +63,7 @@ main = do print x2 print x3 print x4 - print x5 `catch` \(e::SomeException) -> putStrLn "x5: exception" - print x6 `catch` \(e::SomeException) -> putStrLn "x6: exception" + print x5 `catch` \(e::SomeExceptionWithLocation) -> putStrLn "x5: exception" + print x6 `catch` \(e::SomeExceptionWithLocation) -> putStrLn "x6: exception" print x7 print x8 diff --git a/testsuite/tests/indexed-types/should_fail/T5439.hs b/testsuite/tests/indexed-types/should_fail/T5439.hs index d5be550de5..5011e7d388 100644 --- a/testsuite/tests/indexed-types/should_fail/T5439.hs +++ b/testsuite/tests/indexed-types/should_fail/T5439.hs @@ -18,7 +18,7 @@ import Data.Typeable import Control.Exception data Attempt α = Success α - | ∀ e . Exception e ⇒ Failure e + | ∀ e . Exception e ⇒ Failure e data Inject f α = ∀ β . Inject (f β) (α → β) @@ -59,7 +59,7 @@ instance (Typeable n, Exception e) ⇒ Exception (NthException n e) instance WaitOp (WaitOps rs) where type WaitOpResult (WaitOps rs) = HElemOf rs - registerWaitOp ops ev = + registerWaitOp ops ev = let register ∷ ∀ n . HDropClass n rs ⇒ Bool → Peano n → WaitOps (HDrop n rs) → IO Bool register first n (WaitOp op) = do @@ -68,7 +68,7 @@ instance WaitOp (WaitOps rs) where t ← try $ registerWaitOp op (Inject ev $ inj n) r ← case t of Right r → return r - Left e → complete ev $ inj n $ Failure (e ∷ SomeException) + Left e → complete ev $ inj n $ Failure (e ∷ SomeExceptionWithLocation) return $ r || not first register first n (op :? ops') = do let inj n (Success r) = Success (HNth n r) @@ -80,7 +80,7 @@ instance WaitOp (WaitOps rs) where HTailDropComm → register False (PSucc n) ops' Right False → return $ not first Left e → do - c ← complete ev $ inj $ Failure (e ∷ SomeException) + c ← complete ev $ inj $ Failure (e ∷ SomeExceptionWithLocation) return $ c || not first in case waitOpsNonEmpty ops of HNonEmptyInst → register True PZero ops @@ -108,7 +108,7 @@ instance IsPeano PZero where peano = PZero instance IsPeano p ⇒ IsPeano (PSucc p) where - peano = PSucc peano + peano = PSucc peano class (n ~ PSucc (PPred n)) ⇒ PHasPred n where type PPred n @@ -252,4 +252,3 @@ type HNth n l = HHead (HDrop n l) data HElemOf l where HNth ∷ (HDropClass n l, HNonEmpty (HDrop n l)) ⇒ Peano n → HNth n l → HElemOf l - diff --git a/testsuite/tests/indexed-types/should_fail/T5439.stderr b/testsuite/tests/indexed-types/should_fail/T5439.stderr index fb38d71112..55785fbaf5 100644 --- a/testsuite/tests/indexed-types/should_fail/T5439.stderr +++ b/testsuite/tests/indexed-types/should_fail/T5439.stderr @@ -5,11 +5,11 @@ T5439.hs:83:33: error: -> Attempt (HElemOf l0) • Probable cause: ‘($)’ is applied to too few arguments In the second argument of ‘($)’, namely - ‘inj $ Failure (e :: SomeException)’ + ‘inj $ Failure (e :: SomeExceptionWithLocation)’ In a stmt of a 'do' block: - c <- complete ev $ inj $ Failure (e :: SomeException) + c <- complete ev $ inj $ Failure (e :: SomeExceptionWithLocation) In the expression: - do c <- complete ev $ inj $ Failure (e :: SomeException) + do c <- complete ev $ inj $ Failure (e :: SomeExceptionWithLocation) return $ c || not first • Relevant bindings include register :: Bool -> Peano n -> WaitOps (HDrop n rs) -> IO Bool @@ -25,8 +25,8 @@ T5439.hs:83:39: error: • Couldn't match expected type: Peano n0 with actual type: Attempt α0 • In the second argument of ‘($)’, namely - ‘Failure (e :: SomeException)’ + ‘Failure (e :: SomeExceptionWithLocation)’ In the second argument of ‘($)’, namely - ‘inj $ Failure (e :: SomeException)’ + ‘inj $ Failure (e :: SomeExceptionWithLocation)’ In a stmt of a 'do' block: - c <- complete ev $ inj $ Failure (e :: SomeException) + c <- complete ev $ inj $ Failure (e :: SomeExceptionWithLocation) diff --git a/testsuite/tests/numeric/should_run/arith011.hs b/testsuite/tests/numeric/should_run/arith011.hs index e00caad19a..95a2f5f6da 100644 --- a/testsuite/tests/numeric/should_run/arith011.hs +++ b/testsuite/tests/numeric/should_run/arith011.hs @@ -122,7 +122,7 @@ table2 nm op xs ys = do where op' x y = do s <- Control.Exception.catch (evaluate (show (op x y))) - (\e -> return (show (e :: SomeException))) + (\e -> return (show (e :: SomeExceptionWithLocation))) putStrLn (show x ++ " " ++ nm ++ " " ++ show y ++ " = " ++ s) testReadShow zero = do diff --git a/testsuite/tests/printer/PprDynamic.hs b/testsuite/tests/printer/PprDynamic.hs index 5134d8b067..e54fcc1bc4 100644 --- a/testsuite/tests/printer/PprDynamic.hs +++ b/testsuite/tests/printer/PprDynamic.hs @@ -252,10 +252,10 @@ delta ra x = case (eqT ra rt) of Nothing -> x loop = delta rt (MkT delta) -throw# :: SomeException -> a +throw# :: SomeExceptionWithLocation -> a -data SomeException where - SomeException :: Exception e => e -> SomeException +data SomeExceptionWithLocation where + SomeExceptionWithLocation :: Exception e => e -> SomeExceptionWithLocation class (Typeable e, Show e) => Exception e where { } diff --git a/testsuite/tests/rename/should_compile/T11167.hs b/testsuite/tests/rename/should_compile/T11167.hs index 644cc90bed..b7d7940d03 100644 --- a/testsuite/tests/rename/should_compile/T11167.hs +++ b/testsuite/tests/rename/should_compile/T11167.hs @@ -1,21 +1,21 @@ module T11167 where -data SomeException +data SomeExceptionWithLocation newtype ContT r m a = ContT {runContT :: (a -> m r) -> m r} runContT' :: ContT r m a -> (a -> m r) -> m r runContT' = runContT -catch_ :: IO a -> (SomeException -> IO a) -> IO a +catch_ :: IO a -> (SomeExceptionWithLocation -> IO a) -> IO a catch_ = undefined foo :: IO () foo = (undefined :: ContT () IO a) `runContT` (undefined :: a -> IO ()) - `catch_` (undefined :: SomeException -> IO ()) + `catch_` (undefined :: SomeExceptionWithLocation -> IO ()) foo' :: IO () foo' = (undefined :: ContT () IO a) `runContT'` (undefined :: a -> IO ()) - `catch_` (undefined :: SomeException -> IO ()) + `catch_` (undefined :: SomeExceptionWithLocation -> IO ()) diff --git a/testsuite/tests/rename/should_fail/T11167_ambig.hs b/testsuite/tests/rename/should_fail/T11167_ambig.hs index 74df05e5ee..fa7d51aa87 100644 --- a/testsuite/tests/rename/should_fail/T11167_ambig.hs +++ b/testsuite/tests/rename/should_fail/T11167_ambig.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DuplicateRecordFields #-} module T11167_ambig where -data SomeException +data SomeExceptionWithLocation newtype ContT r m a = ContT {runContT :: (a -> m r) -> m r} newtype ContT' r m a = ContT' {runContT :: (a -> m r) -> m r} @@ -9,15 +9,15 @@ newtype ContT' r m a = ContT' {runContT :: (a -> m r) -> m r} runContT' :: ContT r m a -> (a -> m r) -> m r runContT' = runContT -catch_ :: IO a -> (SomeException -> IO a) -> IO a +catch_ :: IO a -> (SomeExceptionWithLocation -> IO a) -> IO a catch_ = undefined foo :: IO () foo = (undefined :: ContT () IO a) `runContT` (undefined :: a -> IO ()) - `catch_` (undefined :: SomeException -> IO ()) + `catch_` (undefined :: SomeExceptionWithLocation -> IO ()) foo' :: IO () foo' = (undefined :: ContT () IO a) `runContT'` (undefined :: a -> IO ()) - `catch_` (undefined :: SomeException -> IO ()) + `catch_` (undefined :: SomeExceptionWithLocation -> IO ()) diff --git a/testsuite/tests/rts/T8035.hs b/testsuite/tests/rts/T8035.hs index 73afc7f205..7065f43ca0 100644 --- a/testsuite/tests/rts/T8035.hs +++ b/testsuite/tests/rts/T8035.hs @@ -7,4 +7,4 @@ import GHC.Conc main = join $ atomically $ do catchSTM (throwSTM ThreadKilled `orElse` return (putStrLn "wtf")) - (\(e::SomeException) -> return (putStrLn "ok")) + (\(e::SomeExceptionWithLocation) -> return (putStrLn "ok")) diff --git a/testsuite/tests/stranal/should_run/T11555a.hs b/testsuite/tests/stranal/should_run/T11555a.hs index fc2e8b83ba..3eee88801b 100644 --- a/testsuite/tests/stranal/should_run/T11555a.hs +++ b/testsuite/tests/stranal/should_run/T11555a.hs @@ -9,12 +9,12 @@ import GHC.Exts type RAW a = ContT () IO a -- See https://gitlab.haskell.org/ghc/ghc/issues/11555 -catchSafe1, catchSafe2 :: IO a -> (SomeException -> IO a) -> IO a +catchSafe1, catchSafe2 :: IO a -> (SomeExceptionWithLocation -> IO a) -> IO a catchSafe1 a b = lazy a `catch` b catchSafe2 a b = join (evaluate a) `catch` b -- | Run and then call a continuation. -runRAW1, runRAW2 :: RAW a -> (Either SomeException a -> IO ()) -> IO () +runRAW1, runRAW2 :: RAW a -> (Either SomeExceptionWithLocation a -> IO ()) -> IO () runRAW1 m k = m `runContT` (k . Right) `catchSafe1` \e -> k $ Left e runRAW2 m k = m `runContT` (k . Right) `catchSafe2` \e -> k $ Left e diff --git a/testsuite/tests/typecheck/should_compile/T5490.hs b/testsuite/tests/typecheck/should_compile/T5490.hs index 487fe0d841..a3539b57e7 100644 --- a/testsuite/tests/typecheck/should_compile/T5490.hs +++ b/testsuite/tests/typecheck/should_compile/T5490.hs @@ -94,7 +94,7 @@ instance WaitOp (WaitOps rs) where t ← try $ registerWaitOp op (Inject ev $ inj n) r ← case t of Right r → return r - Left e → complete ev $ inj n $ Failure (e ∷ SomeException) + Left e → complete ev $ inj n $ Failure (e ∷ SomeExceptionWithLocation) return $ r || not first register first n (op :? ops') = do t ← try $ registerWaitOp op (Inject ev $ inj n) @@ -104,7 +104,7 @@ instance WaitOp (WaitOps rs) where HTailDropComm → register False (PSucc n) ops' Right False → return $ not first Left e → do - c ← complete ev $ inj n $ Failure (e ∷ SomeException) + c ← complete ev $ inj n $ Failure (e ∷ SomeExceptionWithLocation) return $ c || not first case waitOpsNonEmpty ops of HNonEmptyInst → register True PZero ops diff --git a/testsuite/tests/typecheck/should_run/StrictPats.hs b/testsuite/tests/typecheck/should_run/StrictPats.hs index 7eed9dc767..53ed842c06 100644 --- a/testsuite/tests/typecheck/should_run/StrictPats.hs +++ b/testsuite/tests/typecheck/should_run/StrictPats.hs @@ -16,7 +16,7 @@ ok x = do bad :: a -> IO () bad x = do - r <- try @SomeException $ evaluate x + r <- try @SomeExceptionWithLocation $ evaluate x case r of Left _ -> putStrLn "Exception thrown as expected." Right _ -> putStrLn "Exception not thrown when expected." diff --git a/utils/haddock b/utils/haddock -Subproject 5d14361971ec6e6c3dfca282e4b80b307087afe +Subproject 02653b83b36b53246bc72a9427af86806ccef79 |