From 12d023d1b4706665645cc0783dd1ae67625357a3 Mon Sep 17 00:00:00 2001 From: Vladislav Zavialov Date: Wed, 17 Nov 2021 23:57:15 +0300 Subject: testsuite: check for FlexibleContexts in T17563 The purpose of testsuite/tests/typecheck/should_fail/T17563.hs is to make sure we do validity checking on quantified constraints. In particular, see the following functions in GHC.Tc.Validity: * check_quant_pred * check_pred_help * check_class_pred The original bug report used a~b constraints as an example of a constraint that requires validity checking. But with GHC Proposal #371, equality constraints no longer require GADTs or TypeFamilies; instead, they require TypeOperators, which are checked earlier in the pipeline, in the renamer. Rather than simply remove this test, we change the example to use another extension: FlexibleContexts. Since we decide whether a constraint requires this extension in check_class_pred, the regression test continues to exercise the relevant code path. --- testsuite/tests/typecheck/should_fail/T17563.hs | 6 ++++-- testsuite/tests/typecheck/should_fail/T17563.stderr | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/testsuite/tests/typecheck/should_fail/T17563.hs b/testsuite/tests/typecheck/should_fail/T17563.hs index 565cd9f59e..2017db4877 100644 --- a/testsuite/tests/typecheck/should_fail/T17563.hs +++ b/testsuite/tests/typecheck/should_fail/T17563.hs @@ -3,5 +3,7 @@ module T17563 where -blah :: (forall a. a b ~ a c) => b -> c -blah = undefined +data T a b + +blah :: (forall x. Num (T a x)) => T a b +blah = 0 diff --git a/testsuite/tests/typecheck/should_fail/T17563.stderr b/testsuite/tests/typecheck/should_fail/T17563.stderr index 8900a41470..08c077fb7c 100644 --- a/testsuite/tests/typecheck/should_fail/T17563.stderr +++ b/testsuite/tests/typecheck/should_fail/T17563.stderr @@ -1,7 +1,6 @@ -T17563.hs:6:9: error: - • Illegal equational constraint a b ~ a c - • In the quantified constraint ‘forall (a :: * -> *). a b ~ a c’ - In the type signature: blah :: (forall a. a b ~ a c) => b -> c - Suggested fix: - Enable any of the following extensions: GADTs, TypeFamilies +T17563.hs:8:9: error: + • Non type-variable argument in the constraint: Num (T a x) + • In the quantified constraint ‘forall x. Num (T a x)’ + In the type signature: blah :: (forall x. Num (T a x)) => T a b + Suggested fix: Perhaps you intended to use FlexibleContexts -- cgit v1.2.1