Fix panic when running "ghc -H"; trac #3364
authorIan Lynagh <igloo@earth.li>
Thu, 24 Jun 2010 23:40:11 +0000 (23:40 +0000)
committerIan Lynagh <igloo@earth.li>
Thu, 24 Jun 2010 23:40:11 +0000 (23:40 +0000)
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.

compiler/main/CmdLineParser.hs
compiler/utils/Outputable.lhs

index f6b887e..64d218d 100644 (file)
@@ -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)
 
index b948990..ba61a08 100644 (file)
@@ -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