From 6a7ae5edb21444804e9b2ac71018925745bea0b8 Mon Sep 17 00:00:00 2001 From: Tito Sacchi Date: Wed, 18 Aug 2021 14:11:34 +0200 Subject: Emit warning if bang is applied to unlifted types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- testsuite/tests/typecheck/should_compile/T20187a.hs | 7 +++++++ testsuite/tests/typecheck/should_compile/T20187a.stderr | 5 +++++ testsuite/tests/typecheck/should_compile/T20187b.hs | 11 +++++++++++ testsuite/tests/typecheck/should_compile/T20187b.stderr | 5 +++++ testsuite/tests/typecheck/should_compile/all.T | 2 ++ 5 files changed, 30 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/T20187a.hs create mode 100644 testsuite/tests/typecheck/should_compile/T20187a.stderr create mode 100644 testsuite/tests/typecheck/should_compile/T20187b.hs create mode 100644 testsuite/tests/typecheck/should_compile/T20187b.stderr (limited to 'testsuite') 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']) -- cgit v1.2.1