diff options
| author | Sven Tennie <sven.tennie@gmail.com> | 2022-02-06 14:46:16 +0100 |
|---|---|---|
| committer | Sven Tennie <sven.tennie@gmail.com> | 2022-02-17 18:41:33 +0100 |
| commit | 73547190c7c72915bf56e833bf2f64c8406aabd6 (patch) | |
| tree | c925966c92aebe3291c36b08d219b17c16da0d15 | |
| parent | 9e298123c2e3ba52bceca48f4c782f7213a29671 (diff) | |
| download | haskell-73547190c7c72915bf56e833bf2f64c8406aabd6.tar.gz | |
Minimize needed changeset and make root exceptions lazy in their fields
Libraries that work without any changes:
- libraries/array
- libraries/directory
- libraries/process
- libraries/stm
- libraries/unix
libraries/haskeline needs a small change
-------------------------
Metric Decrease:
T9630
Metric Increase:
LargeRecord
MultiComponentModules
MultiComponentModulesRecomp
T15703
T8095
T9872d
-------------------------
61 files changed, 156 insertions, 157 deletions
diff --git a/.gitmodules b/.gitmodules index b0c942d26c..6a78711038 100644 --- a/.gitmodules +++ b/.gitmodules @@ -44,7 +44,7 @@ ignore = untracked [submodule "libraries/array"] path = libraries/array - url = https://gitlab.haskell.org/supersven/array.git + url = https://gitlab.haskell.org/ghc/packages/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/supersven/directory.git + url = https://gitlab.haskell.org/ghc/packages/directory.git ignore = untracked [submodule "libraries/filepath"] path = libraries/filepath @@ -76,16 +76,16 @@ ignore = untracked [submodule "libraries/process"] path = libraries/process - url = https://gitlab.haskell.org/supersven/process.git + url = https://gitlab.haskell.org/ghc/packages/process.git ignore = untracked [submodule "libraries/unix"] path = libraries/unix - url = https://gitlab.haskell.org/supersven/unix.git + url = https://gitlab.haskell.org/ghc/packages/unix.git ignore = untracked branch = 2.7 [submodule "libraries/stm"] path = libraries/stm - url = https://gitlab.haskell.org/supersven/stm.git + url = https://gitlab.haskell.org/ghc/packages/stm.git ignore = untracked [submodule "utils/haddock"] path = utils/haddock diff --git a/compiler/GHC/Data/IOEnv.hs b/compiler/GHC/Data/IOEnv.hs index 1ef6835506..836ca856d0 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 SomeExceptionWithBacktrace r) +tryAllM :: IOEnv env r -> IOEnv env (Either SomeException 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 SomeExceptionWithBacktrace a) +safeTry :: IO a -> IO (Either SomeException 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 :: SomeExceptionWithBacktrace) -> do + `catchException` \(e :: SomeException) -> 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 SomeExceptionWithBacktrace r) +tryMostM :: IOEnv env r -> IOEnv env (Either SomeException r) tryMostM (IOEnv thing) = IOEnv (\ env -> tryMost (thing env)) --------------------------- diff --git a/compiler/GHC/Data/Maybe.hs b/compiler/GHC/Data/Maybe.hs index f50407c9b0..d132dac72f 100644 --- a/compiler/GHC/Data/Maybe.hs +++ b/compiler/GHC/Data/Maybe.hs @@ -1,5 +1,4 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE KindSignatures #-} @@ -31,6 +30,7 @@ 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 (SomeExceptionWithBacktrace _ _) = return Nothing + handler (_ :: SomeException) = return Nothing {- ************************************************************************ diff --git a/compiler/GHC/Prelude.hs b/compiler/GHC/Prelude.hs index b44fa656c4..f61dad9517 100644 --- a/compiler/GHC/Prelude.hs +++ b/compiler/GHC/Prelude.hs @@ -1,7 +1,5 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE ViewPatterns #-} -- | Custom GHC "Prelude" -- @@ -17,12 +15,6 @@ module GHC.Prelude (module X ,module Bits ,shiftL, shiftR -#if __GLASGOW_HASKELL__ < 903 - ,SomeExceptionWithBacktrace - ,pattern SomeExceptionWithBacktrace -#else - ,SomeExceptionWithBacktrace(..) -#endif ) where @@ -45,11 +37,6 @@ 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 ( SomeException(..) ) -#else -import Control.Exception ( SomeExceptionWithBacktrace(..) ) -#endif #if MIN_VERSION_base(4,16,0) import GHC.Bits as Bits hiding (shiftL, shiftR) @@ -99,13 +86,3 @@ shiftR = Bits.shiftR shiftL = Bits.unsafeShiftL shiftR = Bits.unsafeShiftR #endif - -#if __GLASGOW_HASKELL__ < 903 -type SomeExceptionWithBacktrace = SomeException - -{-# COMPLETE SomeExceptionWithBacktrace #-} -pattern SomeExceptionWithBacktrace :: forall. SomeException -> () -> SomeException -pattern SomeExceptionWithBacktrace e unit <- (\x -> ((), x) -> (unit, e)) - where - SomeExceptionWithBacktrace (SomeException e) _ = SomeException e -#endif diff --git a/compiler/GHC/Runtime/Debugger.hs b/compiler/GHC/Runtime/Debugger.hs index c7e06306a0..04709b38cf 100644 --- a/compiler/GHC/Runtime/Debugger.hs +++ b/compiler/GHC/Runtime/Debugger.hs @@ -34,6 +34,7 @@ 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 @@ -264,6 +265,6 @@ pprTypeAndContents id = do docs_term <- case e_term of Right term -> showTerm term Left exn -> return (text "*** Exception:" <+> - text (show (exn :: GHC.Prelude.SomeExceptionWithBacktrace))) + text (show (exn :: SomeException))) 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 53603c01c5..85fd1c8037 100644 --- a/compiler/GHC/Runtime/Eval/Types.hs +++ b/compiler/GHC/Runtime/Eval/Types.hs @@ -22,6 +22,7 @@ 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 @@ -45,7 +46,7 @@ isStep _ = True data ExecResult = ExecComplete - { execResult :: Either SomeExceptionWithBacktrace [Name] + { execResult :: Either SomeException [Name] , execAllocation :: Word64 } | ExecBreak diff --git a/compiler/GHC/Runtime/Interpreter.hs b/compiler/GHC/Runtime/Interpreter.hs index 93d0e07cb1..2c84980513 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 :: SomeExceptionWithBacktrace) -> handleIServFailure iserv e + `catchException` \(e :: SomeException) -> 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 :: SomeExceptionWithBacktrace) -> handleIServFailure iserv e + `catchException` \(e :: SomeException) -> handleIServFailure iserv e -- | Send a value to the iserv process writeIServ :: IServInstance -> Put -> IO () writeIServ iserv put = writePipe (iservPipe iserv) put - `catchException` \(e :: SomeExceptionWithBacktrace) -> handleIServFailure iserv e + `catchException` \(e :: SomeException) -> handleIServFailure iserv e -handleIServFailure :: IServInstance -> SomeExceptionWithBacktrace -> IO a +handleIServFailure :: IServInstance -> SomeException -> 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 3103152d6b..866596598c 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 :: SomeExceptionWithBacktrace -> IO () + let onError :: SomeException -> 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 (SomeExceptionWithBacktrace (SomeException e) _) -> do + Left (e :: SomeException) -> do terminateProcess hProcess cleanup_handles throw e diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs index 3833fb4a26..73b3835282 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 :: SomeExceptionWithBacktrace) -> do + (\(err :: SomeException) -> do errorMsg logger $ text ("Error running clang! you need clang installed to use the" ++ " LLVM backend") $+$ diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs index 7264f2232a..fbaf5afcb2 100644 --- a/compiler/GHC/Tc/Gen/Splice.hs +++ b/compiler/GHC/Tc/Gen/Splice.hs @@ -1042,7 +1042,7 @@ runMeta' show_code ppr_hs run_and_convert expr ; case either_tval of Right v -> return v - Left se -> case fromException se of + Left se -> case (fromException . toException) se of Just IOEnvFailure -> failM -- Error already in Tc monad _ -> fail_with_exn "run" se -- Exception }}} diff --git a/compiler/GHC/Utils/Panic.hs b/compiler/GHC/Utils/Panic.hs index 321b5aeed2..6ea9c959d1 100644 --- a/compiler/GHC/Utils/Panic.hs +++ b/compiler/GHC/Utils/Panic.hs @@ -111,7 +111,11 @@ data GhcException instance Exception GhcException where -- TODO: Print stack traces here +#if __GLASGOW_HASKELL__ < 903 + fromException (SomeException e) +#else fromException (SomeExceptionWithBacktrace (SomeException e) _) +#endif | Just ge <- cast e = Just ge | Just pge <- cast e = Just $ case pge of @@ -139,7 +143,7 @@ safeShowException e = do r <- try (return $! forceList (showException e)) case r of Right msg -> return msg - Left e' -> safeShowException (e' :: SomeExceptionWithBacktrace) + Left e' -> safeShowException (e' :: SomeException) where forceList [] = [] forceList xs@(x : xt) = x `seq` forceList xt `seq` xs @@ -197,18 +201,18 @@ 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 SomeExceptionWithBacktrace a) +tryMost :: IO a -> IO (Either SomeException a) tryMost action = do r <- try action case r of Left se -> - case fromException se of + case (fromException . toException) se of -- Some GhcException's we rethrow, Just (Signal _) -> throwIO se Just (Panic _) -> throwIO se -- others we return Just _ -> return (Left se) Nothing -> - case fromException se of + case (fromException . toException) se of -- All IOExceptions are returned Just (_ :: IOException) -> return (Left se) diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 03e2a1a400..34b3299eb7 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -766,13 +766,23 @@ runGHCi paths maybe_exprs = do runInputTWithPrefs defaultPrefs defaultSettings $ do -- make `ghc -e` exit nonzero on failure, see #7962, #9916, #17560, #18441 _ <- runCommands' hdle - (Just $ hdle (toException $ ExitFailure 1) >> return ()) + (Just $ hdle (convertException $ ExitFailure 1) >> return ()) (return Nothing) return () -- and finally, exit liftIO $ when (verbosity dflags > 0) $ putStrLn "Leaving GHCi." +-- | Convert 'Exception' @e@ to 'SomeException' +-- This is glue code to support both, 'SomeException' (old GHC) and +-- @SomeExceptionWithBacktrace@ (new GHC) as 'Exception' roots. +convertException :: Exception e => e -> SomeException +-- All exceptions are convertible to 'SomeException', +-- thus the 'Nothing' case should never happen! +convertException e = fromMaybe + (error "This should never happen!") $ + (fromException . toException) e + runGHCiInput :: InputT GHCi a -> GHCi a runGHCiInput f = do dflags <- getDynFlags @@ -1048,7 +1058,7 @@ installInteractivePrint (Just ipFun) exprmode = do runCommands :: InputT GHCi (Maybe String) -> InputT GHCi () runCommands gCmd = runCommands' handler Nothing gCmd >> return () -runCommands' :: (SomeExceptionWithBacktrace -> GHCi Bool) -- ^ Exception handler +runCommands' :: (SomeException -> GHCi Bool) -- ^ Exception handler -> Maybe (GHCi ()) -- ^ Source error handler -> InputT GHCi (Maybe String) -> InputT GHCi () @@ -1074,7 +1084,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 :: (SomeExceptionWithBacktrace -> GHCi Bool) -> InputT GHCi (Maybe String) +runOneCommand :: (SomeException -> 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 @@ -1201,9 +1211,9 @@ checkInputForLayout stmt getStmt = do st1 <- getGHCiState let p = prompt st1 setGHCiState st1{ prompt = prompt_cont st1 } - mb_stmt <- ghciHandle (\ex -> case fromException ex of + mb_stmt <- ghciHandle (\ex -> case (fromException . toException) ex of Just UserInterrupt -> return Nothing - _ -> case fromException ex of + _ -> case (fromException . toException) ex of Just ghce -> do liftIO (print (ghce :: GhcException)) return Nothing @@ -2241,7 +2251,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 SomeExceptionWithBacktrace Module of + case e :: Either SomeException Module of Left _ -> return False Right m -> return (not (isMainUnitModule m)) where @@ -4080,7 +4090,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) - (\(_ :: SomeExceptionWithBacktrace) -> lookupModuleInGraph mod_str) + (\(_ :: SomeException) -> 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,21 +4503,21 @@ 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 => SomeExceptionWithBacktrace -> m Bool +handler :: GhciMonad m => SomeException -> m Bool handler exception = do flushInterpBuffers withSignalHandlers $ ghciHandle handler (showException exception >> return False) -showException :: MonadIO m => SomeExceptionWithBacktrace -> m () +showException :: MonadIO m => SomeException -> m () showException se = - liftIO $ case fromException se of + liftIO $ case (fromException . toException) se of -- omit the location for CmdLineError: Just (CmdLineError s) -> putException s -- ditto: Just other_ghc_ex -> putException (show other_ghc_ex) Nothing -> - case fromException se of + case (fromException . toException) se of Just UserInterrupt -> putException "Interrupted." _ -> putException ("*** Exception: " ++ show se) where @@ -4531,13 +4541,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) => (SomeExceptionWithBacktrace -> m a) -> m a -> m a +ghciHandle :: (HasLogger m, ExceptionMonad m) => (SomeException -> 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 SomeExceptionWithBacktrace a) +ghciTry :: ExceptionMonad m => m a -> m (Either SomeException 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 6e51389ce6..7fb13316e9 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 :: SomeExceptionWithBacktrace) -> do + (\(e :: SomeException) -> 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 0760759df1..aede0a9dc1 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 SomeExceptionWithBacktrace (Maybe Bool) + , cmdResult :: Either SomeException (Maybe Bool) , cmdStats :: ActionStats } | CommandIncomplete @@ -441,7 +441,7 @@ runAndPrintStats :: GhciMonad m => (a -> Maybe Integer) -> m a - -> m (ActionStats, Either SomeExceptionWithBacktrace a) + -> m (ActionStats, Either SomeException 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 SomeExceptionWithBacktrace a) + => (a -> Maybe Integer) -> m a -> m (ActionStats, Either SomeException a) runWithStats getAllocs action = do t0 <- liftIO getCurrentTime result <- MC.try action diff --git a/libraries/Cabal b/libraries/Cabal -Subproject f1b880ae92d727b2d2f0d5c4a251750e77d6167 +Subproject 54ab35735057d5b7368fb16fc6e5b8054e17eb4 diff --git a/libraries/array b/libraries/array -Subproject 76767199e8a956f0be6fcb39a492269149f0567 +Subproject 3e4334a6f39d92090bf3ded86b84d7cd1817ce2 diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs index fa602b28a9..3b46494f66 100644 --- a/libraries/base/GHC/Conc/Sync.hs +++ b/libraries/base/GHC/Conc/Sync.hs @@ -95,7 +95,6 @@ module GHC.Conc.Sync import Foreign import Foreign.C -import Data.Typeable import Data.Maybe import GHC.Base @@ -391,19 +390,19 @@ numSparks = IO $ \s -> case numSparks# s of (# s', n #) -> (# s', I# n #) foreign import ccall "&enabled_capabilities" enabled_capabilities :: Ptr CInt -childHandler :: SomeExceptionWithBacktrace -> IO () +childHandler :: SomeException -> 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 :: SomeExceptionWithBacktrace -> IO () +real_handler :: SomeException -> IO () real_handler se - | Just BlockedIndefinitelyOnMVar <- fromException se = return () - | Just BlockedIndefinitelyOnSTM <- fromException se = return () - | Just ThreadKilled <- fromException se = return () - | Just StackOverflow <- fromException se = reportStackOverflow + | Just BlockedIndefinitelyOnMVar <- (fromException . toException) se = return () + | Just BlockedIndefinitelyOnSTM <- (fromException . toException) se = return () + | Just ThreadKilled <- (fromException . toException) se = return () + | Just StackOverflow <- (fromException . toException) se = reportStackOverflow | otherwise = reportError se {- | 'killThread' raises the 'ThreadKilled' exception in the given @@ -888,7 +887,7 @@ reportStackOverflow = do ThreadId tid <- myThreadId c_reportStackOverflow tid -reportError :: SomeExceptionWithBacktrace -> IO () +reportError :: SomeException -> IO () reportError ex = do handler <- getUncaughtExceptionHandler handler ex @@ -902,13 +901,13 @@ foreign import ccall unsafe "reportHeapOverflow" reportHeapOverflow :: IO () {-# NOINLINE uncaughtExceptionHandler #-} -uncaughtExceptionHandler :: IORef (SomeExceptionWithBacktrace -> IO ()) +uncaughtExceptionHandler :: IORef (SomeException -> IO ()) uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler) where - defaultHandler :: SomeExceptionWithBacktrace -> IO () - defaultHandler se@(SomeExceptionWithBacktrace (SomeException ex) _) = do + defaultHandler :: SomeException -> IO () + defaultHandler se = do (hFlush stdout) `catchAny` (\ _ -> return ()) - let msg = case cast ex of + let msg = case (fromException . toException) se of Just Deadlock -> "no threads to run: infinite loop or deadlock?" _ -> showsPrec 0 se "" withCString "%s" $ \cfmt -> @@ -920,8 +919,8 @@ uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler) foreign import ccall unsafe "HsBase.h errorBelch2" errorBelch :: CString -> CString -> IO () -setUncaughtExceptionHandler :: (SomeExceptionWithBacktrace -> IO ()) -> IO () +setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO () setUncaughtExceptionHandler = writeIORef uncaughtExceptionHandler -getUncaughtExceptionHandler :: IO (SomeExceptionWithBacktrace -> IO ()) +getUncaughtExceptionHandler :: IO (SomeException -> IO ()) getUncaughtExceptionHandler = readIORef uncaughtExceptionHandler diff --git a/libraries/base/GHC/Exception/Type.hs b/libraries/base/GHC/Exception/Type.hs index d2544b7ccf..edd3e2e5be 100644 --- a/libraries/base/GHC/Exception/Type.hs +++ b/libraries/base/GHC/Exception/Type.hs @@ -1,7 +1,6 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE BangPatterns #-} {-# OPTIONS_HADDOCK not-home #-} ----------------------------------------------------------------------------- @@ -41,12 +40,12 @@ This additional layer is used to provide a list of 'Backtrace's. @since 4.16.0.0 -} -data SomeExceptionWithBacktrace = SomeExceptionWithBacktrace !SomeException ![Backtrace] +data SomeExceptionWithBacktrace = SomeExceptionWithBacktrace SomeException [Backtrace] -- | Former root of 'Exception's -- Now 'SomeException' is usually wrapped by 'SomeExceptionWithBacktrace'. -- 'SomeException' has been kept as a type for backwards compatibility. -data SomeException = forall e . Exception e => SomeException !e +data SomeException = forall e . Exception e => SomeException e -- @since 4.16.0.0 instance Show SomeExceptionWithBacktrace where diff --git a/libraries/base/GHC/TopHandler.hs b/libraries/base/GHC/TopHandler.hs index e132b44626..daacd5aae0 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 :: SomeExceptionWithBacktrace -> IO a +topHandler :: SomeException -> IO a topHandler err = catch (real_handler safeExit err) topHandler -topHandlerFastExit :: SomeExceptionWithBacktrace -> IO a +topHandlerFastExit :: SomeException -> IO a topHandlerFastExit err = catchException (real_handler fastExit err) topHandlerFastExit @@ -165,10 +165,10 @@ topHandlerFastExit err = -- (e.g. evaluating the string passed to 'error' might generate -- another error, etc.) -- -real_handler :: (Int -> IO a) -> SomeExceptionWithBacktrace -> IO a +real_handler :: (Int -> IO a) -> SomeException -> IO a real_handler exit se = do flushStdHandles -- before any error output - case fromException se of + case (fromException . toException) se of Just StackOverflow -> do reportStackOverflow exit 2 @@ -179,13 +179,13 @@ real_handler exit se = do reportHeapOverflow exit 251 - _ -> case fromException se of + _ -> case (fromException . toException) se of -- only the main thread gets ExitException exceptions Just ExitSuccess -> exit 0 Just (ExitFailure n) -> exit n -- EPIPE errors received for stdout are ignored (#2699) - _ -> catch (case fromException se of + _ -> catch (case (fromException . toException) se of Just IOError{ ioe_type = ResourceVanished, ioe_errno = Just ioe, ioe_handle = Just hdl } diff --git a/libraries/directory b/libraries/directory -Subproject 6563ada11dbe553e5825882389381ef75955fdc +Subproject adb8b4d67356c4eca92f62fd1b7c1ac8add4241 diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index 1f659025a2..c2148d5fdc 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -45,6 +45,7 @@ import Data.Dynamic import Data.Typeable (TypeRep) import Data.IORef import Data.Map (Map) +import Data.Maybe (fromMaybe) import Foreign import GHC.Generics import GHC.Stack.CCS @@ -54,10 +55,6 @@ import System.Exit import System.IO import System.IO.Error -#if __GLASGOW_HASKELL__ < 903 -type SomeExceptionWithBacktrace = SomeException -#endif - -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server @@ -415,16 +412,26 @@ data SerializableException | EOtherException String deriving (Generic, Show) -toSerializableException :: SomeExceptionWithBacktrace -> SerializableException +toSerializableException :: SomeException -> SerializableException toSerializableException ex - | Just UserInterrupt <- fromException ex = EUserInterrupt - | Just (ec::ExitCode) <- fromException ex = (EExitCode ec) - | otherwise = EOtherException (show (ex :: SomeExceptionWithBacktrace)) - -fromSerializableException :: SerializableException -> SomeExceptionWithBacktrace -fromSerializableException EUserInterrupt = toException UserInterrupt -fromSerializableException (EExitCode c) = toException c -fromSerializableException (EOtherException str) = toException (ErrorCall str) + | Just UserInterrupt <- (fromException . toException) ex = EUserInterrupt + | Just (ec::ExitCode) <- (fromException . toException) ex = (EExitCode ec) + | otherwise = EOtherException (show (ex :: SomeException)) + +fromSerializableException :: SerializableException -> SomeException +fromSerializableException EUserInterrupt = convertException UserInterrupt +fromSerializableException (EExitCode c) = convertException c +fromSerializableException (EOtherException str) = convertException (ErrorCall str) + +-- | Convert 'Exception' @e@ to 'SomeException' +-- This is glue code to support both, 'SomeException' (old GHC) and +-- @SomeExceptionWithBacktrace@ (new GHC) as 'Exception' roots. +convertException :: Exception e => e -> SomeException +-- All exceptions are convertible to 'SomeException', +-- thus the 'Nothing' case should never happen! +convertException e = fromMaybe + (error "This should never happen!") $ + (fromException . toException) e instance Binary ExitCode instance Binary SerializableException diff --git a/libraries/haskeline b/libraries/haskeline -Subproject c1bbbf6155ed99a065a99e78e67598664538ab6 +Subproject acb19a203e2f982c0992e03bc6dde484f55e162 diff --git a/libraries/process b/libraries/process -Subproject c85f7475ed36bdb63958217b1fcdc0ec168cfb5 +Subproject 7fd28338c82c89deb3e5db117e87633898046d7 diff --git a/libraries/stm b/libraries/stm -Subproject 321fde3dfc4ef6d92913befbdcf84306457c457 +Subproject a58fdfadbcfd2743944e6a3c4bc734cfbca8913 diff --git a/libraries/unix b/libraries/unix -Subproject 09961d510937bda9a647290a4f7f296683a5e95 +Subproject 1f72ccec55c1b61299310b994754782103a617f diff --git a/testsuite/tests/codeGen/should_run/cgrun025.hs b/testsuite/tests/codeGen/should_run/cgrun025.hs index 8aa91ff610..39255c147d 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 :: SomeExceptionWithBacktrace) -> error "hello, error") + catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeException) -> error "hello, error") diff --git a/testsuite/tests/codeGen/should_run/cgrun025.stderr b/testsuite/tests/codeGen/should_run/cgrun025.stderr index aebfc57099..35ad64c79c 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 :: SomeExceptionWithBacktrace) -> error "hello, error") + catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeException) -> 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 380b135930..98f90db15a 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 SomeExceptionWithBacktrace ()) +main = try (evaluate (f ())) :: IO (Either SomeException ()) f x = g x diff --git a/testsuite/tests/concurrent/should_run/T3279.hs b/testsuite/tests/concurrent/should_run/T3279.hs index 1ae11d138f..d71f4fffdb 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` \(SomeExceptionWithBacktrace e _) -> do + throwIO (ErrorCall "foo") `catch` \(SomeExceptionWithBacktrace (SomeException e) _) -> do myThreadId >>= flip throwTo e -- point X unsafeUnmask $ return 1 main :: IO () main = do - evaluate f `catch` \(SomeExceptionWithBacktrace e _) -> return 0 + evaluate f `catch` \(SomeExceptionWithBacktrace (SomeException e) _) -> return 0 -- the evaluation of 'x' is now suspended at point X tid <- mask_ $ forkIO (evaluate f >> return ()) killThread tid diff --git a/testsuite/tests/concurrent/should_run/T5238.hs b/testsuite/tests/concurrent/should_run/T5238.hs index 40bcde6e70..1de60c4e80 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 ∷ SomeExceptionWithBacktrace) → return ()) + (\(e ∷ SomeException) → 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 7409e31c69..986cb66b27 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 :: SomeExceptionWithBacktrace) + putStrLn $ "caught exception: " ++ show (ex :: SomeException) check readIORef ref >>= print diff --git a/testsuite/tests/concurrent/should_run/allocLimit3.hs b/testsuite/tests/concurrent/should_run/allocLimit3.hs index ead5858be6..28881dc016 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 SomeExceptionWithBacktrace ()) + print (r :: Either SomeException ()) diff --git a/testsuite/tests/concurrent/should_run/async001.hs b/testsuite/tests/concurrent/should_run/async001.hs index f64bb1e069..ab69b1b0fe 100644 --- a/testsuite/tests/concurrent/should_run/async001.hs +++ b/testsuite/tests/concurrent/should_run/async001.hs @@ -16,4 +16,4 @@ main = do threadDelay 1000 killThread t - print x `E.catch` \e -> putStrLn ("main caught: " ++ show (e::SomeExceptionWithBacktrace)) + print x `E.catch` \e -> putStrLn ("main caught: " ++ show (e::SomeException)) diff --git a/testsuite/tests/concurrent/should_run/conc008.hs b/testsuite/tests/concurrent/should_run/conc008.hs index ff22e08398..04630bfc83 100644 --- a/testsuite/tests/concurrent/should_run/conc008.hs +++ b/testsuite/tests/concurrent/should_run/conc008.hs @@ -9,4 +9,4 @@ import Control.Exception main = do id <- myThreadId Control.Exception.catch (killThread id) $ - \e -> putStr (show (e::SomeExceptionWithBacktrace)) + \e -> putStr (show (e::SomeException)) diff --git a/testsuite/tests/concurrent/should_run/conc010.hs b/testsuite/tests/concurrent/should_run/conc010.hs index c6eb72cba6..21ced56f5a 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::SomeExceptionWithBacktrace)) >> putMVar ready2 ())) + (\e -> putStr (show (e::SomeException)) >> putMVar ready2 ())) takeMVar ready throwTo id (ErrorCall "hello") takeMVar ready2 diff --git a/testsuite/tests/concurrent/should_run/conc014.hs b/testsuite/tests/concurrent/should_run/conc014.hs index 36e6dc9d6e..79d7e8f03f 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::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught: " ++ show (e::SomeException)) -- 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/conc015.hs b/testsuite/tests/concurrent/should_run/conc015.hs index d490027784..e7215097ca 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::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught1: " ++ show (e::SomeException)) threadDelay 10000 takeMVar m2 ) `Control.Exception.catch` \e -> do print =<< getMaskingState - putStrLn ("caught2: " ++ show (e::SomeExceptionWithBacktrace)) + putStrLn ("caught2: " ++ show (e::SomeException)) -- 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 ebe4f90b6a..a6a55c12cd 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::SomeExceptionWithBacktrace))) + \e -> putStrLn ("caught1: " ++ show (e::SomeException))) threadDelay 10000 takeMVar m2 ) `Control.Exception.catch` \e -> do print =<< getMaskingState - putStrLn ("caught2: " ++ show (e::SomeExceptionWithBacktrace)) + putStrLn ("caught2: " ++ show (e::SomeException)) -- 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 f1e5d17356..69c171732e 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::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught1: " ++ show (e::SomeException)) putMVar m2 () -- blocked here, "bar" can't be delivered (sum [1..10000] `seq` return ()) `Control.Exception.catch` - \e -> putStrLn ("caught2: " ++ show (e::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught2: " ++ show (e::SomeException)) -- unblocked here, "bar" delivered to "caught3" takeMVar m3 ) `Control.Exception.catch` - \e -> putStrLn ("caught3: " ++ show (e::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught3: " ++ show (e::SomeException)) -- 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 f1e5d17356..69c171732e 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::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught1: " ++ show (e::SomeException)) putMVar m2 () -- blocked here, "bar" can't be delivered (sum [1..10000] `seq` return ()) `Control.Exception.catch` - \e -> putStrLn ("caught2: " ++ show (e::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught2: " ++ show (e::SomeException)) -- unblocked here, "bar" delivered to "caught3" takeMVar m3 ) `Control.Exception.catch` - \e -> putStrLn ("caught3: " ++ show (e::SomeExceptionWithBacktrace)) + \e -> putStrLn ("caught3: " ++ show (e::SomeException)) -- 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 1227ba5f64..7caf32613e 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::SomeExceptionWithBacktrace)) + (\e -> putMVar m (e::SomeException)) 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 009f4a0fa5..9804657aab 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::SomeExceptionWithBacktrace))) + $ \e -> putStrLn ("caught: " ++ show (e::SomeException))) 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 110df623d4..7d8662ae08 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::SomeExceptionWithBacktrace))) + (\e -> throwTo id (e::SomeException))) catch (do yield; performGC; threadDelay 1000000) - (\e -> print (e::SomeExceptionWithBacktrace)) + (\e -> print (e::SomeException)) diff --git a/testsuite/tests/concurrent/should_run/conc033.hs b/testsuite/tests/concurrent/should_run/conc033.hs index 0ab171755b..47c46d366f 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 SomeExceptionWithBacktrace ()) + print (r::Either SomeException ()) diff --git a/testsuite/tests/concurrent/should_run/conc073.hs b/testsuite/tests/concurrent/should_run/conc073.hs index b5c863b92b..64d9d998a6 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::SomeExceptionWithBacktrace + let _ = e::SomeException 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 c564b4ef1f..8d95b34bb6 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::SomeExceptionWithBacktrace) + print (e::SomeException) throwIO e killThread t1 t2 <- uninterruptibleMask_ $ forkIO $ do takeMVar m `catch` \e -> do stat 2 MaskedUninterruptible - print (e::SomeExceptionWithBacktrace) + print (e::SomeException) throwIO e killThread t2 t3 <- mask_ $ forkIOWithUnmask $ \unmask -> diff --git a/testsuite/tests/concurrent/should_run/throwto002.hs b/testsuite/tests/concurrent/should_run/throwto002.hs index 0132214c12..eaaae0c0cb 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::SomeExceptionWithBacktrace) -> run + `catch` \(e::SomeException) -> run diff --git a/testsuite/tests/concurrent/should_run/throwto003.hs b/testsuite/tests/concurrent/should_run/throwto003.hs index 5afb74d5e7..53cd4ccd29 100644 --- a/testsuite/tests/concurrent/should_run/throwto003.hs +++ b/testsuite/tests/concurrent/should_run/throwto003.hs @@ -13,4 +13,4 @@ main = do thread restore m = run where run = (restore $ forever $ modifyMVar_ m $ \v -> if v `mod` 2 == 1 then return (v*2) else return (v-1)) - `catch` \(e::SomeExceptionWithBacktrace) -> run + `catch` \(e::SomeException) -> run diff --git a/testsuite/tests/deSugar/should_run/T246.hs b/testsuite/tests/deSugar/should_run/T246.hs index a88bef2653..2845db3ab0 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 - (\(_::SomeExceptionWithBacktrace) -> print "caught") -- x first, and hit "undefined" + (\(_::SomeException) -> print "caught") -- x first, and hit "undefined" } diff --git a/testsuite/tests/ffi/should_run/IncallAffinity.hs b/testsuite/tests/ffi/should_run/IncallAffinity.hs index 198040bc9d..386e9950e8 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 :: SomeExceptionWithBacktrace -> IO Int + handle :: SomeException -> 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 a7a1c447f9..3874d6ed68 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 SomeExceptionWithBacktrace ExecResult) + MC.try $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeException 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 a7be85d972..d77738e3c9 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 :: SomeExceptionWithBacktrace) + Left err -> return $ show (err :: SomeException) putStrLn x where a :: String diff --git a/testsuite/tests/ghci.debugger/scripts/T8487.stdout b/testsuite/tests/ghci.debugger/scripts/T8487.stdout index 2405650a35..eca4364202 100644 --- a/testsuite/tests/ghci.debugger/scripts/T8487.stdout +++ b/testsuite/tests/ghci.debugger/scripts/T8487.stdout @@ -1,4 +1,5 @@ -Breakpoint 0 activated at T8487.hs:(5,8)-(7,66) -Stopped in Main.f, T8487.hs:(5,8)-(7,66) +Breakpoint 0 activated at T8487.hs:(5,8)-(7,53) +Stopped in Main.f, T8487.hs:(5,8)-(7,53) _result :: IO String = _ -ma :: Either SomeExceptionWithBacktrace String = Left _ +ma :: Either SomeException String = Left + (SomeException (ErrorCallWithLocation ...)) diff --git a/testsuite/tests/ghci/should_run/T19628.hs b/testsuite/tests/ghci/should_run/T19628.hs index a395332319..74891c690f 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::SomeExceptionWithBacktrace) -> putStrLn "x5: exception" - print x6 `catch` \(e::SomeExceptionWithBacktrace) -> putStrLn "x6: exception" + print x5 `catch` \(e::SomeException) -> putStrLn "x5: exception" + print x6 `catch` \(e::SomeException) -> 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 8c75e801fa..0dbcbcc1a8 100644 --- a/testsuite/tests/indexed-types/should_fail/T5439.hs +++ b/testsuite/tests/indexed-types/should_fail/T5439.hs @@ -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 ∷ SomeExceptionWithBacktrace) + Left e → complete ev $ inj n $ Failure (e ∷ SomeException) 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 ∷ SomeExceptionWithBacktrace) + c ← complete ev $ inj $ Failure (e ∷ SomeException) return $ c || not first in case waitOpsNonEmpty ops of HNonEmptyInst → register True PZero ops diff --git a/testsuite/tests/indexed-types/should_fail/T5439.stderr b/testsuite/tests/indexed-types/should_fail/T5439.stderr index c9b581cfb1..fb38d71112 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 :: SomeExceptionWithBacktrace)’ + ‘inj $ Failure (e :: SomeException)’ In a stmt of a 'do' block: - c <- complete ev $ inj $ Failure (e :: SomeExceptionWithBacktrace) + c <- complete ev $ inj $ Failure (e :: SomeException) In the expression: - do c <- complete ev $ inj $ Failure (e :: SomeExceptionWithBacktrace) + do c <- complete ev $ inj $ Failure (e :: SomeException) 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 :: SomeExceptionWithBacktrace)’ + ‘Failure (e :: SomeException)’ In the second argument of ‘($)’, namely - ‘inj $ Failure (e :: SomeExceptionWithBacktrace)’ + ‘inj $ Failure (e :: SomeException)’ In a stmt of a 'do' block: - c <- complete ev $ inj $ Failure (e :: SomeExceptionWithBacktrace) + c <- complete ev $ inj $ Failure (e :: SomeException) diff --git a/testsuite/tests/numeric/should_run/arith011.hs b/testsuite/tests/numeric/should_run/arith011.hs index e434aaa105..e00caad19a 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 :: SomeExceptionWithBacktrace))) + (\e -> return (show (e :: SomeException))) putStrLn (show x ++ " " ++ nm ++ " " ++ show y ++ " = " ++ s) testReadShow zero = do diff --git a/testsuite/tests/rts/T8035.hs b/testsuite/tests/rts/T8035.hs index b7f45ada2b..73afc7f205 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::SomeExceptionWithBacktrace) -> return (putStrLn "ok")) + (\(e::SomeException) -> return (putStrLn "ok")) diff --git a/testsuite/tests/stranal/should_run/T11555a.hs b/testsuite/tests/stranal/should_run/T11555a.hs index 8fef013938..fc2e8b83ba 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 -> (SomeExceptionWithBacktrace -> IO a) -> IO a +catchSafe1, catchSafe2 :: IO a -> (SomeException -> 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 SomeExceptionWithBacktrace a -> IO ()) -> IO () +runRAW1, runRAW2 :: RAW a -> (Either SomeException 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 a1a6adfa3f..487fe0d841 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 ∷ SomeExceptionWithBacktrace) + Left e → complete ev $ inj n $ Failure (e ∷ SomeException) 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 ∷ SomeExceptionWithBacktrace) + c ← complete ev $ inj n $ Failure (e ∷ SomeException) 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 71decdb469..7eed9dc767 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 @SomeExceptionWithBacktrace $ evaluate x + r <- try @SomeException $ evaluate x case r of Left _ -> putStrLn "Exception thrown as expected." Right _ -> putStrLn "Exception not thrown when expected." |
