summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile
diff options
context:
space:
mode:
authorJakob Brünker <jakob.bruenker@gmail.com>2021-06-26 14:19:29 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-27 06:15:11 -0400
commit3e71874b32725cb0bd95f6a7effc77190a860b3e (patch)
treea36430a7c277e713e4fb2f25b24f526be499efe4 /testsuite/tests/typecheck/should_compile
parentb1792fefaf61099541157aaf77a6835ab7a09958 (diff)
downloadhaskell-3e71874b32725cb0bd95f6a7effc77190a860b3e.tar.gz
Tc: Allow Typeable in quantified constraints
Previously, when using Typeable in a quantified constraint, GHC would complain that user-specified instances of Typeable aren't allowed. This was because checking for SigmaCtxt was missing from a check for whether an instance head is a hand-written binding. Fixes #20033
Diffstat (limited to 'testsuite/tests/typecheck/should_compile')
-rw-r--r--testsuite/tests/typecheck/should_compile/T20033.hs17
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
2 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T20033.hs b/testsuite/tests/typecheck/should_compile/T20033.hs
new file mode 100644
index 0000000000..24323a238b
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T20033.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE UndecidableInstances #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE QuantifiedConstraints #-}
+{-# LANGUAGE ConstraintKinds #-}
+
+module T20033 where
+
+import Data.Typeable
+
+data Some c where
+ Some :: c a => a -> Some c
+
+extractSome :: (Typeable a, forall x. c x => Typeable x) => Some c -> Maybe a
+extractSome (Some a) = cast a
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 429ac69ce0..a275d5196a 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -792,3 +792,4 @@ test('T18481', normal, compile, [''])
test('T18481a', normal, compile, [''])
test('T19775', normal, compile, [''])
test('T17817b', normal, compile, [''])
+test('T20033', normal, compile, [''])