Throw error if safe imports used when safe haskell isn't on
authorDavid Terei <davidterei@gmail.com>
Wed, 9 Nov 2011 01:15:27 +0000 (17:15 -0800)
committerDavid Terei <davidterei@gmail.com>
Wed, 9 Nov 2011 02:01:13 +0000 (18:01 -0800)
compiler/rename/RnNames.lhs

index 02ed64f..f300a02 100644 (file)
@@ -214,6 +214,10 @@ rnImportDecl this_mod
     dflags <- getDOpts
     warnIf (want_boot && not (mi_boot iface) && isOneShot (ghcMode dflags))
            (warnRedundantSourceImport imp_mod_name)
+    when (mod_safe && not (safeImportsOn dflags)) $
+        addErrAt loc (ptext (sLit "safe import can't be used as Safe Haskell isn't on!")
+                  $+$ ptext (sLit $ "please enable Safe Haskell through either"
+                                 ++ "-XSafe, -XTruswrothy or -XUnsafe"))
 
     let
         imp_mod    = mi_module iface