summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2023-01-03 23:40:48 +0200
committerOleg Grenrus <oleg.grenrus@iki.fi>2023-05-16 07:59:21 +0300
commitbdb93cd28f4a40e9a9f28b0976ca8fa4f250cad2 (patch)
tree4b61e2541b49be36f20a07b05a9625d791e2177e /testsuite
parenta8f0435fc5516ad978064eeabcc24776b6b86351 (diff)
downloadhaskell-bdb93cd28f4a40e9a9f28b0976ca8fa4f250cad2.tar.gz
Add -Wmissing-role-annotations
Implements #22702
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/linters/notes.stdout2
-rw-r--r--testsuite/tests/warnings/should_compile/T22702a.hs25
-rw-r--r--testsuite/tests/warnings/should_compile/T22702a.stderr6
-rw-r--r--testsuite/tests/warnings/should_compile/T22702b.hs23
-rw-r--r--testsuite/tests/warnings/should_compile/all.T2
5 files changed, 58 insertions, 0 deletions
diff --git a/testsuite/tests/linters/notes.stdout b/testsuite/tests/linters/notes.stdout
index 0e82fe5214..a269670e43 100644
--- a/testsuite/tests/linters/notes.stdout
+++ b/testsuite/tests/linters/notes.stdout
@@ -34,6 +34,8 @@ ref compiler/GHC/Tc/Instance/Family.hs:474:35: Note [Constrained family i
ref compiler/GHC/Tc/Module.hs:711:15: Note [Extra dependencies from .hs-boot files]
ref compiler/GHC/Tc/Solver/Rewrite.hs:1009:7: Note [Stability of rewriting]
ref compiler/GHC/Tc/TyCl.hs:1130:6: Note [Unification variables need fresh Names]
+ref compiler/GHC/Tc/TyCl.hs:4982:17: Note [Missing role annotations warning]
+ref compiler/GHC/Tc/TyCl.hs:5008:3: Note [Missing role annotations warning]
ref compiler/GHC/Tc/Types.hs:692:33: Note [Extra dependencies from .hs-boot files]
ref compiler/GHC/Tc/Types.hs:1423:47: Note [Care with plugin imports]
ref compiler/GHC/Tc/Types/Constraint.hs:226:34: Note [NonCanonical Semantics]
diff --git a/testsuite/tests/warnings/should_compile/T22702a.hs b/testsuite/tests/warnings/should_compile/T22702a.hs
new file mode 100644
index 0000000000..14b0b94047
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T22702a.hs
@@ -0,0 +1,25 @@
+{-# OPTIONS_GHC -Wmissing-role-annotations #-}
+{-# LANGUAGE RoleAnnotations #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE StandaloneKindSignatures #-}
+module T22702a where
+
+import Data.Kind (Type)
+
+-- type with parameters
+-- warns
+type Foo :: Type -> Type -> Type
+data Foo x y = Foo x
+
+-- type without parameters
+-- doesn't warn
+data Quu = Quu1 | Quu2
+
+-- polykinded type
+-- warns, no role for `k`
+type Bar :: (k -> Type) -> k -> Type
+data Bar f a = Bar (f a)
+
+-- type-class may have roles as well
+-- doesn't warn
+class C a where
diff --git a/testsuite/tests/warnings/should_compile/T22702a.stderr b/testsuite/tests/warnings/should_compile/T22702a.stderr
new file mode 100644
index 0000000000..c407c64b7d
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T22702a.stderr
@@ -0,0 +1,6 @@
+
+T22702a.hs:12:1: warning: [GHC-65490] [-Wmissing-role-annotations]
+ Missing role annotation: type role Foo representational phantom
+
+T22702a.hs:21:1: warning: [GHC-65490] [-Wmissing-role-annotations]
+ Missing role annotation: type role Bar representational nominal
diff --git a/testsuite/tests/warnings/should_compile/T22702b.hs b/testsuite/tests/warnings/should_compile/T22702b.hs
new file mode 100644
index 0000000000..b9bb929f77
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T22702b.hs
@@ -0,0 +1,23 @@
+{-# OPTIONS_GHC -Wmissing-role-annotations #-}
+{-# LANGUAGE RoleAnnotations #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE StandaloneKindSignatures #-}
+module T22702b where
+
+import Data.Kind (Type)
+
+-- type with parameters
+type Foo :: Type -> Type -> Type
+type role Foo representational phantom
+data Foo x y = Foo x
+
+-- type without parameters
+data Quu = Quu1 | Quu2
+
+-- polykinded type
+type Bar :: (k -> Type) -> k -> Type
+type role Bar representational nominal
+data Bar f a = Bar (f a)
+
+-- type-class may have roles as well
+class C a where
diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T
index f001e40164..8697709203 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -62,3 +62,5 @@ test('T22759', normal, compile, [''])
test('T22676', [extra_files(['src'])], multimod_compile, ['src.hs', '-working-dir src -Wmissing-home-modules -v0'])
test('DodgyImports', normal, compile, ['-Wdodgy-imports'])
test('DodgyImports_hiding', normal, compile, ['-Wdodgy-imports'])
+test('T22702a', normal, compile, [''])
+test('T22702b', normal, compile, [''])