From 9789e8454ad9f315169063b344a56c4216c12711 Mon Sep 17 00:00:00 2001 From: Zachary Wood Date: Sun, 14 Aug 2022 22:13:38 -0700 Subject: tc: warn about lazy annotations on unlifted arguments (fixes #21951) --- testsuite/tests/typecheck/should_compile/T21951a.hs | 10 ++++++++++ testsuite/tests/typecheck/should_compile/T21951a.stderr | 4 ++++ testsuite/tests/typecheck/should_compile/T21951b.hs | 13 +++++++++++++ testsuite/tests/typecheck/should_compile/T21951b.stderr | 4 ++++ testsuite/tests/typecheck/should_compile/all.T | 2 ++ 5 files changed, 33 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/T21951a.hs create mode 100644 testsuite/tests/typecheck/should_compile/T21951a.stderr create mode 100644 testsuite/tests/typecheck/should_compile/T21951b.hs create mode 100644 testsuite/tests/typecheck/should_compile/T21951b.stderr (limited to 'testsuite') diff --git a/testsuite/tests/typecheck/should_compile/T21951a.hs b/testsuite/tests/typecheck/should_compile/T21951a.hs new file mode 100644 index 0000000000..fb4bd85422 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21951a.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# LANGUAGE StrictData #-} +{-# LANGUAGE MagicHash #-} + +module Wibble where + +import Data.Kind +import GHC.Exts + +data UA = UA ~(Array# Int) diff --git a/testsuite/tests/typecheck/should_compile/T21951a.stderr b/testsuite/tests/typecheck/should_compile/T21951a.stderr new file mode 100644 index 0000000000..d6afb5465e --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21951a.stderr @@ -0,0 +1,4 @@ +T21951a.hs:10:11: warning: [-Wredundant-strictness-flags] + Lazy flag has no effect on unlifted type ‘Array# Int’ + In the definition of data constructor ‘UA’ + In the data type declaration for ‘UA’ diff --git a/testsuite/tests/typecheck/should_compile/T21951b.hs b/testsuite/tests/typecheck/should_compile/T21951b.hs new file mode 100644 index 0000000000..de975e3843 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21951b.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# LANGUAGE StrictData #-} +{-# LANGUAGE MagicHash #-} + +module Wibble where + +import Data.Kind +import GHC.Exts + +type U :: UnliftedType +data U = MkU Int + +data T = T ~U diff --git a/testsuite/tests/typecheck/should_compile/T21951b.stderr b/testsuite/tests/typecheck/should_compile/T21951b.stderr new file mode 100644 index 0000000000..f26dbe8ce2 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21951b.stderr @@ -0,0 +1,4 @@ +T21951b.hs:13:10: warning: [-Wredundant-strictness-flags] + Lazy flag has no effect on unlifted type ‘U’ + 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 22c5dc2647..dae6e5bca7 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -853,3 +853,5 @@ test('DeepSubsumption06', normal, compile, ['-XHaskell98']) test('DeepSubsumption07', normal, compile, ['-XHaskell2010']) test('DeepSubsumption08', normal, compile, ['']) test('DeepSubsumption09', normal, compile, ['']) +test('T21951a', normal, compile, ['-Wredundant-strictness-flags']) +test('T21951b', normal, compile, ['-Wredundant-strictness-flags']) -- cgit v1.2.1