summaryrefslogtreecommitdiff
path: root/docs/users_guide/safe_haskell.rst
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2019-05-06 23:14:52 +0300
committerBen Gamari <ben@smart-cactus.org>2019-06-25 23:25:08 -0400
commita863c44f35720b760054e949de1b2f431f32774e (patch)
treedac3585b3b42570dd2afd2b2a2297f67ef52d580 /docs/users_guide/safe_haskell.rst
parent5c3f20801c4149d6a950cfb36c7a841dd32d17e0 (diff)
downloadhaskell-a863c44f35720b760054e949de1b2f431f32774e.tar.gz
Add -Winferred-safe-imports warning
This commit partly reverts e69619e923e84ae61a6bb4357f06862264daa94b commit by reintroducing Sf_SafeInferred SafeHaskellMode. We preserve whether module was declared or inferred Safe. When declared-Safe module imports inferred-Safe, we warn. This inferred status is volatile, often enough it's a happy coincidence, something which cannot be relied upon. However, explicitly Safe or Trustworthy packages won't accidentally become Unsafe. Updates haddock submodule.
Diffstat (limited to 'docs/users_guide/safe_haskell.rst')
-rw-r--r--docs/users_guide/safe_haskell.rst35
1 files changed, 34 insertions, 1 deletions
diff --git a/docs/users_guide/safe_haskell.rst b/docs/users_guide/safe_haskell.rst
index bf7f1fb5d0..af016194bf 100644
--- a/docs/users_guide/safe_haskell.rst
+++ b/docs/users_guide/safe_haskell.rst
@@ -740,7 +740,7 @@ And one general flag:
requiring the package that ``M`` resides in be considered trusted, for ``M``
to be considered trusted.
-And three warning flags:
+And four warning flags:
.. ghc-flag:: -Wunsafe
:shortdesc: warn if the module being compiled is regarded to be unsafe.
@@ -777,6 +777,39 @@ And three warning flags:
-XSafe , a more informative bound. Can be used to detect once a Safe Haskell
bound can be improved as dependencies are updated.
+.. ghc-flag:: -Winferred-safe-imports
+ :shortdesc: warn when an explicitly Safe Haskell module imports a Safe-Inferred one
+ :type: dynamic
+ :reverse: -Wno-inferred-safe-imports
+ :category:
+
+ :since: 8.10.1
+
+ .. index::
+ single: safe haskell imports, warning
+
+ The module ``A`` below is annotated to be explictly ``Safe``, but it imports
+ ``Safe-Inferred`` module.
+
+ {-# LANGUAGE Safe #-}
+ module A where
+
+ import B (double)
+
+ quad :: Int -> Int
+ quad = double . double
+
+
+ module B where
+
+ double :: Int -> Int
+ double n = n + n
+
+ The inferred status is volatile: if an unsafe import is added to the module
+ ``B``, it will cause compilation error of ``A``. When
+ :ghc-flag:`-Winferred-safe-imports` is enabled, the compiler will emit a
+ warning about this.
+
.. _safe-compilation:
Safe Compilation