diff options
author | Tito Sacchi <tito.sakki@gmail.com> | 2021-08-18 14:11:34 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-09-17 09:36:31 -0400 |
commit | 6a7ae5edb21444804e9b2ac71018925745bea0b8 (patch) | |
tree | 532274a4f13492d9b9708539412510d0287a6646 /docs | |
parent | 4564f00fdeb5e072e8f91fec72a6393f0e3f0703 (diff) | |
download | haskell-6a7ae5edb21444804e9b2ac71018925745bea0b8.tar.gz |
Emit warning if bang is applied to unlifted types
GHC will trigger a warning similar to the following when a strictness
flag is applied to an unlifted type (primitive or defined with the
Unlifted* extensions) in the definition of a data constructor.
Test.hs:7:13: warning: [-Wredundant-strictness-flags]
• Strictness flag has no effect on unlifted type ‘Int#’
• In the definition of data constructor ‘TestCon’
In the data type declaration for ‘Test’
|
7 | data Test = TestCon !Int#
| ^^^^^^^^^^^^^
Fixes #20187
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/9.4.1-notes.rst | 6 | ||||
-rw-r--r-- | docs/users_guide/using-warnings.rst | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/docs/users_guide/9.4.1-notes.rst b/docs/users_guide/9.4.1-notes.rst index 2f3d822f45..aae0c065d7 100644 --- a/docs/users_guide/9.4.1-notes.rst +++ b/docs/users_guide/9.4.1-notes.rst @@ -3,6 +3,12 @@ Version 9.4.1 ============== +Compiler +~~~~~~~~ + +- New :ghc-flag:`-Wredundant-strictness-flags` that checks for strictness flags + (``!``) applied to unlifted types, which are always strict. + ``base`` library ~~~~~~~~~~~~~~~~ diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 1f658e8167..4cae76ec5a 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -1917,6 +1917,20 @@ of ``-W(no-)*``. would report that the ``P{x, y, ..}`` match has a redundant use of ``..``. +.. ghc-flag:: -Wredundant-strictness-flags + :shortdesc: Warn about redundant strictness flags. + :type: dynamic + :reverse: -Wno-redundant-strictness-flags + :category: + + :since: 9.4 + + Report strictness flags applied to unlifted types. An unlifted type is + always strict, and applying a strictness flag has no effect. + + For example: :: + + data T = T !Int# .. ghc-flag:: -Wwrong-do-bind :shortdesc: warn about do bindings that appear to throw away monadic values |