summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-07-08 11:02:43 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-09 08:47:22 -0400
commit2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250 (patch)
tree9b308c925d387cada0126db89850a9820ab9307c /compiler/GHC/Utils
parent60fabd7eb3e3450636673d818075da19074ddad0 (diff)
downloadhaskell-2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250.tar.gz
Avoid unsafePerformIO for getProgName
getProgName was used to append the name of the program (e.g. "ghc") to printed error messages in the Show instance of GhcException. It doesn't belong here as GHCi and GHC API users may want to override this behavior by setting a different error handler. So we now call it in the defaultErrorHandler instead.
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r--compiler/GHC/Utils/Panic.hs5
-rw-r--r--compiler/GHC/Utils/Panic/Plain.hs12
2 files changed, 2 insertions, 15 deletions
diff --git a/compiler/GHC/Utils/Panic.hs b/compiler/GHC/Utils/Panic.hs
index 497ea65003..04e94b81d4 100644
--- a/compiler/GHC/Utils/Panic.hs
+++ b/compiler/GHC/Utils/Panic.hs
@@ -19,7 +19,6 @@ module GHC.Utils.Panic
, throwGhcExceptionIO
, handleGhcException
- , GHC.Utils.Panic.Plain.progName
, pgmError
, panic
, pprPanic
@@ -124,9 +123,7 @@ instance Exception GhcException where
| otherwise = Nothing
instance Show GhcException where
- showsPrec _ e@(ProgramError _) = showGhcExceptionUnsafe e
- showsPrec _ e@(CmdLineError _) = showString "<command line>: " . showGhcExceptionUnsafe e
- showsPrec _ e = showString progName . showString ": " . showGhcExceptionUnsafe e
+ showsPrec _ e = showGhcExceptionUnsafe e
-- | Show an exception as a string.
showException :: Exception e => e -> String
diff --git a/compiler/GHC/Utils/Panic/Plain.hs b/compiler/GHC/Utils/Panic/Plain.hs
index 709bbaf152..355c1c039d 100644
--- a/compiler/GHC/Utils/Panic/Plain.hs
+++ b/compiler/GHC/Utils/Panic/Plain.hs
@@ -22,8 +22,6 @@ module GHC.Utils.Panic.Plain
, cmdLineError, cmdLineErrorIO
, assertPanic
, assert, assertM, massert
-
- , progName
) where
import GHC.Settings.Config
@@ -31,7 +29,6 @@ import GHC.Utils.Constants
import GHC.Utils.Exception as Exception
import GHC.Stack
import GHC.Prelude
-import System.Environment
import System.IO.Unsafe
-- | This type is very similar to 'GHC.Utils.Panic.GhcException', but it omits
@@ -69,14 +66,7 @@ data PlainGhcException
instance Exception PlainGhcException
instance Show PlainGhcException where
- showsPrec _ e@(PlainProgramError _) = showPlainGhcException e
- showsPrec _ e@(PlainCmdLineError _) = showString "<command line>: " . showPlainGhcException e
- showsPrec _ e = showString progName . showString ": " . showPlainGhcException e
-
--- | The name of this GHC.
-progName :: String
-progName = unsafePerformIO (getProgName)
-{-# NOINLINE progName #-}
+ showsPrec _ e = showPlainGhcException e
-- | Short usage information to display when we are given the wrong cmd line arguments.
short_usage :: String