diff options
author | HE, Tao <sighingnow@gmail.com> | 2018-06-15 13:45:42 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-06-15 13:47:42 -0400 |
commit | 91822e4eee295a42f69489c7e9e878b296e897bc (patch) | |
tree | f601b1c1f052da905ea7ff3134a8f32a409a3ffe /testsuite/tests/quantified-constraints | |
parent | b67b971740e77ba5e9e2892ac0f668d41c38381f (diff) | |
download | haskell-91822e4eee295a42f69489c7e9e878b296e897bc.tar.gz |
Add "quantified constraint" context in error message, fix #15231.
This patch adds "quantified constraint" context in error message when
UndecidableInstances checking fails for quantified constraints.
See Trac #15231:comment#1.
This patch also pretty-prints the instance head for better error messages.
Test Plan: make test TEST="T15231"
Reviewers: bgamari, simonpj
Reviewed By: simonpj
Subscribers: simonpj, rwbarton, thomie, carter
GHC Trac Issues: #15231
Differential Revision: https://phabricator.haskell.org/D4819
Diffstat (limited to 'testsuite/tests/quantified-constraints')
-rw-r--r-- | testsuite/tests/quantified-constraints/T15231.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/quantified-constraints/T15231.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/quantified-constraints/all.T | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/quantified-constraints/T15231.hs b/testsuite/tests/quantified-constraints/T15231.hs new file mode 100644 index 0000000000..7b7834d1f2 --- /dev/null +++ b/testsuite/tests/quantified-constraints/T15231.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE QuantifiedConstraints #-} +module Bug where + +import Data.Kind + +data ECC :: Constraint -> Type -> Type + +class Y a +class Z a + +instance c => Y (ECC c a) +instance (c => Z a) => Z (ECC c a) diff --git a/testsuite/tests/quantified-constraints/T15231.stderr b/testsuite/tests/quantified-constraints/T15231.stderr new file mode 100644 index 0000000000..afb7ac3a25 --- /dev/null +++ b/testsuite/tests/quantified-constraints/T15231.stderr @@ -0,0 +1,7 @@ + +T15231.hs:15:10: error: + • Variable ‘c’ occurs more often + in the constraint ‘c’ than in the instance head ‘Z a’ + (Use UndecidableInstances to permit this) + • In the quantified constraint ‘c => Z a’ + In the instance declaration for ‘Z (ECC c a)’ diff --git a/testsuite/tests/quantified-constraints/all.T b/testsuite/tests/quantified-constraints/all.T index e546a7c495..75fcf8c772 100644 --- a/testsuite/tests/quantified-constraints/all.T +++ b/testsuite/tests/quantified-constraints/all.T @@ -9,3 +9,4 @@ test('T14863', normal, compile, ['']) test('T14961', normal, compile, ['']) test('T9123a', normal, compile, ['']) test('T15244', normal, compile, ['']) +test('T15231', normal, compile_fail, ['']) |