Add tests for #8128 and #8740
authorRyan Scott <ryan.gl.scott@gmail.com>
Sun, 3 Jun 2018 11:47:51 +0000 (07:47 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Sun, 3 Jun 2018 11:48:42 +0000 (07:48 -0400)
Commit 08073e16cf672d8009309e4e55d4566af1ecaff4 (#11066) ended up
fixing these, fortunately enough.

testsuite/tests/deriving/should_compile/T8128.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/T8128.stderr [new file with mode: 0644]
testsuite/tests/deriving/should_compile/T8740.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/T8740.stderr [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T

diff --git a/testsuite/tests/deriving/should_compile/T8128.hs b/testsuite/tests/deriving/should_compile/T8128.hs
new file mode 100644 (file)
index 0000000..624702e
--- /dev/null
@@ -0,0 +1,9 @@
+{-# LANGUAGE StandaloneDeriving, GADTs, FlexibleInstances #-}
+
+module T8128 where
+
+data T a where
+  MkT1 :: T Int
+  MkT2 :: Bool -> T Bool
+
+deriving instance Show (T Int)
diff --git a/testsuite/tests/deriving/should_compile/T8128.stderr b/testsuite/tests/deriving/should_compile/T8128.stderr
new file mode 100644 (file)
index 0000000..5f8b130
--- /dev/null
@@ -0,0 +1,14 @@
+
+T8128.hs:9:1: warning: [-Winaccessible-code (in -Wdefault)]
+    • Couldn't match type ‘Int’ with ‘Bool’
+      Inaccessible code in
+        a pattern with constructor: MkT2 :: Bool -> T Bool,
+        in an equation for ‘showsPrec’
+    • In the pattern: MkT2 b1
+      In an equation for ‘showsPrec’:
+          showsPrec a (MkT2 b1)
+            = showParen (a >= 11) ((.) (showString "MkT2 ") (showsPrec 11 b1))
+      When typechecking the code for ‘showsPrec’
+        in a derived instance for ‘Show (T Int)’:
+        To see the code I am typechecking, use -ddump-deriv
+      In the instance declaration for ‘Show (T Int)’
diff --git a/testsuite/tests/deriving/should_compile/T8740.hs b/testsuite/tests/deriving/should_compile/T8740.hs
new file mode 100644 (file)
index 0000000..95a114c
--- /dev/null
@@ -0,0 +1,17 @@
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE StandaloneDeriving #-}
+module T8740 where
+
+data Abstract
+data Reified
+data Player
+
+data Elect p a where
+    ElectRefAsTypeOf :: Int -> Elect Abstract a -> Elect Abstract a
+    ElectHandle :: a -> Elect Reified a
+    Controller :: Elect Abstract Player
+    Owner :: Elect Abstract Player
+    You :: Elect Abstract Player
+
+deriving instance (Eq a) => Eq (Elect p a)
+deriving instance (Ord a) => Ord (Elect p a)
diff --git a/testsuite/tests/deriving/should_compile/T8740.stderr b/testsuite/tests/deriving/should_compile/T8740.stderr
new file mode 100644 (file)
index 0000000..9b60741
--- /dev/null
@@ -0,0 +1,18 @@
+
+T8740.hs:17:1: warning: [-Winaccessible-code (in -Wdefault)]
+    • Couldn't match type ‘Reified’ with ‘Abstract’
+      Inaccessible code in
+        a pattern with constructor:
+          ElectRefAsTypeOf :: forall a.
+                              Int -> Elect Abstract a -> Elect Abstract a,
+        in a case alternative
+    • In the pattern: ElectRefAsTypeOf {}
+      In a case alternative: ElectRefAsTypeOf {} -> GT
+      In the expression:
+        case b of
+          ElectRefAsTypeOf {} -> GT
+          ElectHandle b1 -> (a1 `compare` b1)
+          _ -> LT
+      When typechecking the code for ‘compare’
+        in a derived instance for ‘Ord (Elect p a)’:
+        To see the code I am typechecking, use -ddump-deriv
index b2dd670..0e0494f 100644 (file)
@@ -44,11 +44,13 @@ test('T7710', normal, compile, [''])
 
 test('AutoDeriveTypeable', normal, compile, [''])
 
+test('T8128', normal, compile, [''])
 test('T8138', reqlib('primitive'), compile, ['-O2'])
 test('T8165', normal, compile, [''])
 test('T8631', normal, compile, [''])
 test('T8758', [], multimod_compile, ['T8758a', '-v0'])
 test('T8678', normal, compile, [''])
+test('T8740', normal, compile, [''])
 test('T8865', normal, compile, [''])
 test('T8893', normal, compile, [''])
 test('T8950', normal, compile, [''])