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 /testsuite | |
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 'testsuite')
5 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T20187a.hs b/testsuite/tests/typecheck/should_compile/T20187a.hs new file mode 100644 index 0000000000..ce76330c88 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20187a.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE MagicHash #-} + +module T20187a where + +import GHC.Exts + +data T = T !Int# diff --git a/testsuite/tests/typecheck/should_compile/T20187a.stderr b/testsuite/tests/typecheck/should_compile/T20187a.stderr new file mode 100644 index 0000000000..7fcde05809 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20187a.stderr @@ -0,0 +1,5 @@ + +T20187a.hs:7:10: warning: [-Wredundant-strictness-flags] + • Strictness flag has no effect on unlifted type ‘Int#’ + • In the definition of data constructor ‘T’ + In the data type declaration for ‘T’ diff --git a/testsuite/tests/typecheck/should_compile/T20187b.hs b/testsuite/tests/typecheck/should_compile/T20187b.hs new file mode 100644 index 0000000000..8f766cbb40 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20187b.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures, MagicHash, DataKinds, UnliftedDatatypes #-} + +module T20187b where + +import GHC.Exts +import GHC.Types + +type IntU :: UnliftedType +data IntU = IntU Int# + +data T = T !IntU diff --git a/testsuite/tests/typecheck/should_compile/T20187b.stderr b/testsuite/tests/typecheck/should_compile/T20187b.stderr new file mode 100644 index 0000000000..2f0d5c601b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20187b.stderr @@ -0,0 +1,5 @@ + +T20187b.hs:11:10: warning: [-Wredundant-strictness-flags] + • Strictness flag has no effect on unlifted type ‘IntU’ + • In the definition of data constructor ‘T’ + In the data type declaration for ‘T’ diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 72105683a5..b6735408db 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -796,3 +796,5 @@ test('T20033', normal, compile, ['']) test('TypeRepCon', normal, compile, ['-Woverlapping-patterns']) test('T20181', normal, compile, ['']) test('T20241', normal, compile, ['']) +test('T20187a', normal, compile, ['-Wredundant-strictness-flags']) +test('T20187b', normal, compile, ['-Wredundant-strictness-flags']) |