summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-08-02 14:25:21 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-08-02 14:25:21 +0100
commitf49079a3c6b349340018dddbfe962654997397a1 (patch)
tree407cd5c050d1a6feb8e67fdeba7095f72862d07b /compiler/main
parentbdf364e86560ddb25676c259a331b7fcd722d26d (diff)
parentdd96a196e4719d04ba78675069e93d01a50b7b33 (diff)
downloadhaskell-f49079a3c6b349340018dddbfe962654997397a1.tar.gz
Merge branch 'master' of http://darcs.haskell.org/ghc
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/HscMain.lhs27
1 files changed, 16 insertions, 11 deletions
diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs
index 2603d21bc4..5ae01766e9 100644
--- a/compiler/main/HscMain.lhs
+++ b/compiler/main/HscMain.lhs
@@ -946,8 +946,11 @@ checkSafeImports dflags hsc_env tcg_env
(modulePackageId m)
-- Is a module trusted? Return Nothing if True, or a String
- -- if it isn't, containing the reason it isn't
- isModSafe :: Module -> SrcSpan -> Hsc (Maybe SDoc)
+ -- if it isn't, containing the reason it isn't. Also return
+ -- if the module trustworthy (true) or safe (false) so we know
+ -- if we should check if the package itself is trusted in the
+ -- future.
+ isModSafe :: Module -> SrcSpan -> Hsc (Maybe SDoc, Bool)
isModSafe m l = do
iface <- lookup' m
case iface of
@@ -965,11 +968,12 @@ checkSafeImports dflags hsc_env tcg_env
-- check package is trusted
safeP = packageTrusted trust trust_own_pkg m
if safeM && safeP
- then return Nothing
- else return $ Just $ if safeM
- then text "The package (" <> ppr (modulePackageId m) <>
- text ") the module resides in isn't trusted."
- else text "The module itself isn't safe."
+ then return (Nothing, trust == Sf_Trustworthy)
+ else let err = Just $ if safeM
+ then text "The package (" <> ppr (modulePackageId m) <>
+ text ") the module resides in isn't trusted."
+ else text "The module itself isn't safe."
+ in return (err, False)
-- Here we check the transitive package trust requirements are OK still.
checkPkgTrust :: [PackageId] -> Hsc ()
@@ -990,14 +994,15 @@ checkSafeImports dflags hsc_env tcg_env
checkSafe :: (Module, SrcSpan, IsSafeImport) -> Hsc (Maybe PackageId)
checkSafe (_, _, False) = return Nothing
checkSafe (m, l, True ) = do
- module_safe <- isModSafe m l
+ (module_safe, tw) <- isModSafe m l
case module_safe of
- Nothing -> return pkg
+ Nothing -> return $ pkg tw
Just s -> liftIO $ throwIO $ mkSrcErr $ unitBag $ mkPlainErrMsg l
$ ppr m <+> text "can't be safely imported!"
<+> s
- where pkg | isHomePkg m = Nothing
- | otherwise = Just (modulePackageId m)
+ where pkg False = Nothing
+ pkg True | isHomePkg m = Nothing
+ | otherwise = Just (modulePackageId m)
--------------------------------------------------------------
-- Simplifiers