summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-10-14 11:21:45 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-15 01:36:14 -0400
commit426b0ddc79890f80a8ceeef135371533f066b9ba (patch)
treea2eefaa3d05d2007090d36b8e82c781ed662a0e5 /testsuite/tests/typecheck
parenta2d3594ca173905502d3de2f4e25ef9e36d41906 (diff)
downloadhaskell-426b0ddc79890f80a8ceeef135371533f066b9ba.tar.gz
Don't skip validity checks for built-in classes (#17355)
Issue #17355 occurred because the control flow for `TcValidity.check_valid_inst_head` was structured in such a way that whenever it checked a special, built-in class (like `Generic` or `HasField`), it would skip the most important check of all: `checkValidTypePats`, which rejects nonsense like this: ```hs instance Generic (forall a. a) ``` This fixes the issue by carving out `checkValidTypePats` from `check_valid_inst_head` so that `checkValidTypePats` is always invoked. `check_valid_inst_head` has also been renamed to `check_special_inst_head` to reflect its new purpose of _only_ checking for instances headed by special classes. Fixes #17355.
Diffstat (limited to 'testsuite/tests/typecheck')
-rw-r--r--testsuite/tests/typecheck/should_fail/T17355.hs11
-rw-r--r--testsuite/tests/typecheck/should_fail/T17355.stderr9
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T17355.hs b/testsuite/tests/typecheck/should_fail/T17355.hs
new file mode 100644
index 0000000000..cf9fb651cc
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T17355.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE RankNTypes, DataKinds #-}
+module T17355 where
+
+import GHC.Generics
+import GHC.Records
+
+data Foo = Foo { poly :: forall a. a -> a }
+
+instance Generic (forall a . a)
+instance HasField "myPoly" Foo (forall a. a -> a) where
+ getField (Foo x) = x
diff --git a/testsuite/tests/typecheck/should_fail/T17355.stderr b/testsuite/tests/typecheck/should_fail/T17355.stderr
new file mode 100644
index 0000000000..5212ef8787
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T17355.stderr
@@ -0,0 +1,9 @@
+
+T17355.hs:9:10: error:
+ • Illegal polymorphic type: forall a. a
+ • In the instance declaration for ‘Generic (forall a. a)’
+
+T17355.hs:10:10: error:
+ • Illegal polymorphic type: forall a. a -> a
+ • In the instance declaration for
+ ‘HasField "myPoly" Foo (forall a. a -> a)’
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 6b66d41975..18e94f7974 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -544,3 +544,4 @@ test('UnliftedNewtypesMultiFieldGadt', normal, compile_fail, [''])
test('T13834', normal, compile_fail, [''])
test('T17077', normal, compile_fail, [''])
test('T17213', [extra_files(['T17213a.hs'])], multimod_compile_fail, ['T17213', '-v0'])
+test('T17355', normal, compile_fail, [''])