From: Ian Lynagh Date: Thu, 24 Jun 2010 23:40:11 +0000 (+0000) Subject: Fix panic when running "ghc -H"; trac #3364 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=888b4e89a4a4e3f39a3ba567c796b3a79b63bf61 Fix panic when running "ghc -H"; trac #3364 The problem is that showing SDoc's looks at the static flags global variables, but those are panics while we are parsing the static flags. We work around this by explicitly using a fixed prettyprinter style. --- diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs index f6b887e..64d218d 100644 --- a/compiler/main/CmdLineParser.hs +++ b/compiler/main/CmdLineParser.hs @@ -184,5 +184,5 @@ putCmdLineState s = CmdLineP $ \_ -> ((),s) errorsToGhcException :: [Located String] -> GhcException errorsToGhcException errs = let errors = vcat [ ppr l <> text ": " <> text e | L l e <- errs ] - in UsageError (showSDoc errors) + in UsageError (showSDoc $ withPprStyle cmdlineParserStyle errors) diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs index b948990..ba61a08 100644 --- a/compiler/utils/Outputable.lhs +++ b/compiler/utils/Outputable.lhs @@ -56,7 +56,7 @@ module Outputable ( codeStyle, userStyle, debugStyle, dumpStyle, asmStyle, ifPprDebug, qualName, qualModule, mkErrStyle, defaultErrStyle, defaultDumpStyle, defaultUserStyle, - mkUserStyle, Depth(..), + mkUserStyle, cmdlineParserStyle, Depth(..), -- * Error handling and debugging utilities pprPanic, assertPprPanic, pprPanicFastInt, pprPgmError, @@ -186,6 +186,9 @@ mkUserStyle :: PrintUnqualified -> Depth -> PprStyle mkUserStyle unqual depth | opt_PprStyle_Debug = PprDebug | otherwise = PprUser unqual depth + +cmdlineParserStyle :: PprStyle +cmdlineParserStyle = PprUser alwaysQualify AllTheWay \end{code} Orthogonal to the above printing styles are (possibly) some