summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2023-04-04 18:16:41 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-04-04 17:13:40 -0400
commitc165f079a13232a44689c55a61c70e2c9aea5464 (patch)
tree26e87f84df040e00b85af4dad6b3d0701d138673
parent7c16f3be6e1ac92f87d752f12ad6c6e7b7fd6207 (diff)
downloadhaskell-c165f079a13232a44689c55a61c70e2c9aea5464.tar.gz
Add testcase for #23192
This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192
-rw-r--r--testsuite/tests/typecheck/should_compile/T23192.hs16
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
2 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T23192.hs b/testsuite/tests/typecheck/should_compile/T23192.hs
new file mode 100644
index 0000000000..be7ddf133d
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T23192.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -Werror=redundant-constraints #-}
+
+module EventThing where
+
+class Monad m => Event m where
+ thingsForEvent :: m [Int]
+
+class Monad m => Thingy m where
+ thingies :: m [Int]
+
+-- Check that we don't get a redundant constraint warning for "Monad m".
+-- See #19690.
+instance (Monad m, Event m) => Thingy m where
+ thingies = thingsForEvent
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 4c200961f4..b2232d8f6e 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -870,3 +870,4 @@ test('T21443', normal, compile, [''])
test('QualifiedRecordUpdate',
[ extra_files(['QualifiedRecordUpdate_aux.hs']) ]
, multimod_compile, ['QualifiedRecordUpdate', '-v0'])
+test('T23192', normal, compile, [''])