From c165f079a13232a44689c55a61c70e2c9aea5464 Mon Sep 17 00:00:00 2001 From: sheaf <sam.derbyshire@gmail.com> Date: Tue, 4 Apr 2023 18:16:41 +0200 Subject: [PATCH] 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 --- .../tests/typecheck/should_compile/T23192.hs | 16 ++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 2 files changed, 17 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/T23192.hs diff --git a/testsuite/tests/typecheck/should_compile/T23192.hs b/testsuite/tests/typecheck/should_compile/T23192.hs new file mode 100644 index 000000000000..be7ddf133daa --- /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 4c200961f4f2..b2232d8f6ede 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, ['']) -- GitLab