summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-12-21 15:23:36 -0800
committerDavid Terei <davidterei@gmail.com>2011-12-22 21:27:48 -0800
commit541781f280e007b511038046c85babc45e99959b (patch)
tree7f2c74ad5229e4bd7086b59363c482ee8cef1a2a
parenta20cdb930a6f9e980521e0767867217ed96033f4 (diff)
downloadhaskell-541781f280e007b511038046c85babc45e99959b.tar.gz
Fix :issafe safe haskell ghci command
-rw-r--r--ghc/InteractiveUI.hs32
1 files changed, 24 insertions, 8 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 62727c543a..cc4be40f44 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -1412,23 +1412,39 @@ isSafeModule m = do
(GHC.moduleNameString $ GHC.moduleName m))
let iface' = fromJust iface
- trust = showPpr $ getSafeMode $ GHC.mi_trust iface'
- pkg = if packageTrusted dflags m then "trusted" else "untrusted"
- (good, bad) = tallyPkgs dflags $
- map fst $ filter snd $ dep_pkgs $ GHC.mi_deps iface'
+
+ trust = showPpr $ getSafeMode $ GHC.mi_trust iface'
+ pkgT = packageTrusted dflags m
+ pkg = if pkgT then "trusted" else "untrusted"
+ (good', bad') = tallyPkgs dflags $
+ map fst $ filter snd $ dep_pkgs $ GHC.mi_deps iface'
+ (good, bad) = case GHC.mi_trust_pkg iface' of
+ True | pkgT -> (modulePackageId m:good', bad')
+ True -> (good', modulePackageId m:bad')
+ False -> (good', bad')
liftIO $ putStrLn $ "Trust type is (Module: " ++ trust ++ ", Package: " ++ pkg ++ ")"
- when (not $ null good)
+ liftIO $ putStrLn $ "Package Trust: "
+ ++ (if packageTrustOn dflags then "On" else "Off")
+
+ when (packageTrustOn dflags && not (null good))
(liftIO $ putStrLn $ "Trusted package dependencies (trusted): " ++
(intercalate ", " $ map packageIdString good))
- if (null bad)
- then liftIO $ putStrLn $ mname ++ " is trusted!"
- else do
+
+ case goodTrust (getSafeMode $ GHC.mi_trust iface') of
+ True | (null bad || not (packageTrustOn dflags)) ->
+ liftIO $ putStrLn $ mname ++ " is trusted!"
+
+ True -> do
liftIO $ putStrLn $ "Trusted package dependencies (untrusted): "
++ (intercalate ", " $ map packageIdString bad)
liftIO $ putStrLn $ mname ++ " is NOT trusted!"
+ False -> liftIO $ putStrLn $ mname ++ " is NOT trusted!"
+
where
+ goodTrust t = t `elem` [Sf_Safe, Sf_SafeInfered, Sf_Trustworthy]
+
mname = GHC.moduleNameString $ GHC.moduleName m
packageTrusted dflags md