diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-03-16 18:36:59 +0100 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-03-16 18:38:58 +0100 |
commit | 5166ee94e439375a4e6acb80f88ec6ee65476bbd (patch) | |
tree | f79b90d82c995faea5e03c66ae2f19920b90f52f /compiler/utils/Outputable.hs | |
parent | beee618c4ab8f725acd4dce3ef8a0d4ce84bb6ec (diff) | |
download | haskell-5166ee94e439375a4e6acb80f88ec6ee65476bbd.tar.gz |
Dont call unsafeGlobalDynFlags if it is not set
Parsing of static and mode flags happens before any session is started,
i.e., before the first call to 'GHC.withGhc'. Therefore, to report
errors for invalid usage of these two types of flags, we can not call
any function that needs DynFlags, as there are no DynFlags available yet
(unsafeGlobalDynFlags is not set either). So we always print "on the
commandline" as the location, which is true except for Api users, which
is probably ok.
When reporting errors for invalid usage of dynamic flags we /can/ make
use of DynFlags, and we do so explicitly in
DynFlags.parseDynamicFlagsFull.
Before, we called unsafeGlobalDynFlags when an invalid (combination of)
flag(s) was given on the commandline, resulting in panics (#9963). This
regression was introduced in 1d6124de.
Also rename showSDocSimple to showSDocUnsafe, to hopefully prevent this
from happening again.
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D730
GHC Trac Issues: #9963
Diffstat (limited to 'compiler/utils/Outputable.hs')
-rw-r--r-- | compiler/utils/Outputable.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index c557224fc1..e6e8e02dda 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -40,7 +40,7 @@ module Outputable ( -- * Converting 'SDoc' into strings and outputing it printForC, printForAsm, printForUser, printForUserPartWay, pprCode, mkCodeStyle, - showSDoc, showSDocSimple, showSDocOneLine, + showSDoc, showSDocUnsafe, showSDocOneLine, showSDocForUser, showSDocDebug, showSDocDump, showSDocDumpOneLine, showSDocUnqual, showPpr, renderWithStyle, @@ -406,8 +406,10 @@ mkCodeStyle = PprCode showSDoc :: DynFlags -> SDoc -> String showSDoc dflags sdoc = renderWithStyle dflags sdoc defaultUserStyle -showSDocSimple :: SDoc -> String -showSDocSimple sdoc = showSDoc unsafeGlobalDynFlags sdoc +-- showSDocUnsafe is unsafe, because `unsafeGlobalDynFlags` might not be +-- initialised yet. +showSDocUnsafe :: SDoc -> String +showSDocUnsafe sdoc = showSDoc unsafeGlobalDynFlags sdoc showPpr :: Outputable a => DynFlags -> a -> String showPpr dflags thing = showSDoc dflags (ppr thing) |