summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-07-07 20:14:14 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-11 17:47:41 -0400
commitb507acebdc3dbec53c54ae07175b39da4066d4f8 (patch)
treecb0ee4f150e047927e4499075eb35ca724327dab /testsuite
parent01ec8549871ebc43db3a7e28324222fa739c6531 (diff)
downloadhaskell-b507acebdc3dbec53c54ae07175b39da4066d4f8.tar.gz
Don't typecheck too much (or too little) in DerivingVia (#16923)
Previously, GHC would typecheck the `via` type once per class in a `deriving` clause, which caused the problems observed in #16923. This patch restructures some of the functionality in `TcDeriv` and `TcHsType` to avoid this problem. We now typecheck the `via` type exactly once per `deriving` clause and *then* typecheck all of the classes in the clause. See `Note [Don't typecheck too much in DerivingVia]` in `TcDeriv` for the full details.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/deriving/should_fail/T16923.hs4
-rw-r--r--testsuite/tests/deriving/should_fail/T16923.stderr6
-rw-r--r--testsuite/tests/deriving/should_fail/all.T1
3 files changed, 11 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_fail/T16923.hs b/testsuite/tests/deriving/should_fail/T16923.hs
new file mode 100644
index 0000000000..eaa845864b
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T16923.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE DerivingVia #-}
+module T16923 where
+
+data Foo deriving () via Maybe Maybe
diff --git a/testsuite/tests/deriving/should_fail/T16923.stderr b/testsuite/tests/deriving/should_fail/T16923.stderr
new file mode 100644
index 0000000000..b17e673b30
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T16923.stderr
@@ -0,0 +1,6 @@
+
+T16923.hs:4:32: error:
+ • Expecting one more argument to ‘Maybe’
+ Expected a type, but ‘Maybe’ has kind ‘* -> *’
+ • In the first argument of ‘Maybe’, namely ‘Maybe’
+ In the data declaration for ‘Foo’
diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T
index 1f674805a3..bbef97bec7 100644
--- a/testsuite/tests/deriving/should_fail/all.T
+++ b/testsuite/tests/deriving/should_fail/all.T
@@ -73,6 +73,7 @@ test('T14728b', normal, compile_fail, [''])
test('T14916', normal, compile_fail, [''])
test('T15073', [extra_files(['T15073a.hs'])], multimod_compile_fail,
['T15073', '-v0'])
+test('T16923', normal, compile_fail, [''])
test('deriving-via-fail', normal, compile_fail, [''])
test('deriving-via-fail2', normal, compile_fail, [''])
test('deriving-via-fail3', normal, compile_fail, [''])