Ticket #5988: 0003-Update-safe-haskell-error-warn-formatting.patch

File 0003-Update-safe-haskell-error-warn-formatting.patch, 4.0 KB (added by dterei, 3 years ago)

GHC patch 3

  • compiler/main/HscMain.hs

    From a50f480227d2ace8ba51360f17da9f7f4544783e Mon Sep 17 00:00:00 2001
    From: David Terei <[email protected]>
    Date: Tue, 3 Apr 2012 12:37:30 -0700
    Subject: [PATCH 3/4] Update safe haskell error/warn formatting
    
    ---
     compiler/main/HscMain.hs |   29 +++++++++++++----------------
     1 files changed, 13 insertions(+), 16 deletions(-)
    
    diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
    index 15a175f..f8e2b5d 100644
    a b hscCheckSafe' dflags m l = do 
    10111011        case iface of
    10121012            -- can't load iface to check trust!
    10131013            Nothing -> throwErrors $ unitBag $ mkPlainErrMsg l
    1014                         $ text "Can't load the interface file for" <+> ppr m <>
    1015                           text ", to check that it can be safely imported"
     1014                         $ text "Can't load the interface file for" <+> ppr m
     1015                           <> text ", to check that it can be safely imported"
    10161016
    10171017            -- got iface, check trust
    10181018            Just iface' -> do
    hscCheckSafe' dflags m l = do 
    10261026                    -- General errors we throw but Safe errors we log
    10271027                    (True, True ) -> return $ trust == Sf_Trustworthy
    10281028                    (True, False) -> liftIO . throwIO $ pkgTrustErr
    1029                     (False, _   ) -> logWarnings modTrustErr >> return (trust == Sf_Trustworthy)
     1029                    (False, _   ) -> logWarnings modTrustErr
     1030                                     >> return (trust == Sf_Trustworthy)
    10301031
    10311032                where
    10321033                    pkgTrustErr = mkSrcErr $ unitBag $ mkPlainErrMsg l $
    1033                         sep [ ppr (moduleName m) <> text ":"
    1034                             , text "Can't be safely imported!"
     1034                        sep [ ppr (moduleName m)
     1035                                <> text ": Can't be safely imported!"
    10351036                            , text "The package (" <> ppr (modulePackageId m)
    1036                                   <> text ") the module resides in isn't trusted."
     1037                                <> text ") the module resides in isn't trusted."
    10371038                            ]
    10381039                    modTrustErr = unitBag $ mkPlainErrMsg l $
    1039                         sep [ ppr (moduleName m) <> text ":"
    1040                             , text "Can't be safely imported!"
     1040                        sep [ ppr (moduleName m)
     1041                                <> text ": Can't be safely imported!"
    10411042                            , text "The module itself isn't safe." ]
    10421043
    10431044    -- | Check the package a module resides in is trusted. Safe compiled
    checkPkgTrust dflags pkgs = 
    10811082            = Nothing
    10821083            | otherwise
    10831084            = Just $ mkPlainErrMsg noSrcSpan
    1084                    $ text "The package (" <> ppr pkg <> text ") is required"
    1085                   <> text " to be trusted but it isn't!"
     1085                   $ text "The package (" <> ppr pkg <> text ") is required" <>
     1086                    text " to be trusted but it isn't!"
    10861087
    10871088-- | Set module to unsafe and wipe trust information.
    10881089--
    wipeTrust tcg_env whyUnsafe = do 
    11061107    whyUnsafe' df = vcat [ text "Warning:" <+> quotes pprMod
    11071108                             <+> text "has been infered as unsafe!"
    11081109                       , text "Reason:"
    1109                        , nest 4 $
    1110                            (vcat $ badFlags df) $+$
    1111                            (vcat $ pprErrMsgBagWithLoc whyUnsafe)
     1110                       , nest 4 $ (vcat $ badFlags df) $+$
     1111                                  (vcat $ pprErrMsgBagWithLoc whyUnsafe)
    11121112                       ]
    1113 
    11141113    badFlags df   = concat $ map (badFlag df) unsafeFlags
    1115 
    11161114    badFlag df (str,loc,on,_)
    11171115        | on df     = [mkLocMessage (loc df) $
    11181116                            text str <+> text "is not allowed in Safe Haskell"]
    11191117        | otherwise = []
    11201118
    1121 
    11221119--------------------------------------------------------------
    11231120-- Simplifiers
    11241121--------------------------------------------------------------