summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_fail
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-07-25 16:14:27 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2017-07-25 16:14:27 -0400
commit6bb32ba78580271921e3d5c3c98afac2c1b68de4 (patch)
tree6ed5c55ec28f127d534d504829ec277b6ec5739b /testsuite/tests/deriving/should_fail
parent36b270a94e689220c77ab49a863435dda6b60621 (diff)
downloadhaskell-6bb32ba78580271921e3d5c3c98afac2c1b68de4.tar.gz
Fix #10684 by processing deriving clauses with finer grain
Summary: Previously, one could experience error cascades with deriving clauses when one class in a set of many failed to derive, causing the other derived classes to be skipped entirely and resulting in other errors down the line. The solution is to process each class in a data type's set of deriving clauses individually, and engineer it so that failure to derive an individual class within that set doesn't cancel out the others. Test Plan: make test TEST="T10684 T12801" Reviewers: austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #10684, #12801 Differential Revision: https://phabricator.haskell.org/D3771
Diffstat (limited to 'testsuite/tests/deriving/should_fail')
-rw-r--r--testsuite/tests/deriving/should_fail/T10684.hs4
-rw-r--r--testsuite/tests/deriving/should_fail/T10684.stderr5
-rw-r--r--testsuite/tests/deriving/should_fail/T12801.hs8
-rw-r--r--testsuite/tests/deriving/should_fail/T12801.stderr5
-rw-r--r--testsuite/tests/deriving/should_fail/all.T2
5 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_fail/T10684.hs b/testsuite/tests/deriving/should_fail/T10684.hs
new file mode 100644
index 0000000000..fdda0c7e46
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T10684.hs
@@ -0,0 +1,4 @@
+module A where
+import GHC.Generics
+data A = A deriving (Show, Generic)
+data B = B A deriving (Show)
diff --git a/testsuite/tests/deriving/should_fail/T10684.stderr b/testsuite/tests/deriving/should_fail/T10684.stderr
new file mode 100644
index 0000000000..6cdbac2301
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T10684.stderr
@@ -0,0 +1,5 @@
+
+T10684.hs:3:28: error:
+ • Can't make a derived instance of ‘Generic A’:
+ You need DeriveGeneric to derive an instance for this class
+ • In the data declaration for ‘A’
diff --git a/testsuite/tests/deriving/should_fail/T12801.hs b/testsuite/tests/deriving/should_fail/T12801.hs
new file mode 100644
index 0000000000..22bbdf0aae
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T12801.hs
@@ -0,0 +1,8 @@
+data Container
+ = Container [Wibble Int]
+ deriving (Eq, Show)
+
+data Wibble a
+ = Wibble a
+ | Wobble
+ deriving (Eq, Functor, Show)
diff --git a/testsuite/tests/deriving/should_fail/T12801.stderr b/testsuite/tests/deriving/should_fail/T12801.stderr
new file mode 100644
index 0000000000..7bc63df715
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T12801.stderr
@@ -0,0 +1,5 @@
+
+T12801.hs:8:17: error:
+ • Can't make a derived instance of ‘Functor Wibble’:
+ You need DeriveFunctor to derive an instance for this class
+ • In the data declaration for ‘Wibble’
diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T
index 9f3781ccf0..5fa589f321 100644
--- a/testsuite/tests/deriving/should_fail/all.T
+++ b/testsuite/tests/deriving/should_fail/all.T
@@ -60,7 +60,9 @@ test('T10598_fail3', normal, compile_fail, [''])
test('T10598_fail4', normal, compile_fail, [''])
test('T10598_fail5', normal, compile_fail, [''])
test('T10598_fail6', normal, compile_fail, [''])
+test('T10684', normal, compile_fail, [''])
test('T11509_1', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
compile_fail, [''])
test('T12163', normal, compile_fail, [''])
test('T12512', omit_ways(['ghci']), compile_fail, [''])
+test('T12801', normal, compile_fail, [''])