summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-09-26 10:53:32 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-09-26 12:34:51 +0100
commit1a88f9a4fb373ce52284996212fc23b06848b1c0 (patch)
treef47edfba08918411312ea1825d5392d3cde43caf /testsuite/tests/typecheck/should_fail
parent8c9d0ce490506fdc60d9f25d4b80774180cf92ce (diff)
downloadhaskell-1a88f9a4fb373ce52284996212fc23b06848b1c0.tar.gz
Improve error messages from functional dependencies
Reponding to Trac #9612: * Track the CtOrigin of a Derived equality, arising from a functional dependency * And report it clearly in the error stream This relies on a previous commit, in which I stop dropping Derived insolubles on the floor.
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
-rw-r--r--testsuite/tests/typecheck/should_fail/FDsFromGivens.stderr22
-rw-r--r--testsuite/tests/typecheck/should_fail/T5236.stderr15
-rw-r--r--testsuite/tests/typecheck/should_fail/T5978.stderr13
-rw-r--r--testsuite/tests/typecheck/should_fail/T9612.hs20
-rw-r--r--testsuite/tests/typecheck/should_fail/T9612.stderr20
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail143.stderr13
7 files changed, 79 insertions, 25 deletions
diff --git a/testsuite/tests/typecheck/should_fail/FDsFromGivens.stderr b/testsuite/tests/typecheck/should_fail/FDsFromGivens.stderr
index 56d3006260..f3320d0d8e 100644
--- a/testsuite/tests/typecheck/should_fail/FDsFromGivens.stderr
+++ b/testsuite/tests/typecheck/should_fail/FDsFromGivens.stderr
@@ -1,10 +1,12 @@
-
-FDsFromGivens.hs:21:15:
- Could not deduce (C Char [a]) arising from a use of ‘f’
- from the context (C Char Char)
- bound by a pattern with constructor
- KCC :: C Char Char => () -> KCC,
- in an equation for ‘bar’
- at FDsFromGivens.hs:21:6-10
- In the expression: f
- In an equation for ‘bar’: bar (KCC _) = f
+
+FDsFromGivens.hs:21:15:
+ Couldn't match type ‘Char’ with ‘[a0]’
+ arising from a functional dependency between constraints:
+ ‘C Char [a0]’ arising from a use of ‘f’ at FDsFromGivens.hs:21:15
+ ‘C Char Char’
+ arising from a pattern with constructor
+ KCC :: C Char Char => () -> KCC,
+ in an equation for ‘bar’
+ at FDsFromGivens.hs:21:6-10
+ In the expression: f
+ In an equation for ‘bar’: bar (KCC _) = f
diff --git a/testsuite/tests/typecheck/should_fail/T5236.stderr b/testsuite/tests/typecheck/should_fail/T5236.stderr
index 557a0413c9..8a723bab9b 100644
--- a/testsuite/tests/typecheck/should_fail/T5236.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5236.stderr
@@ -1,5 +1,10 @@
-
-T5236.hs:17:5:
- No instance for (Id A B) arising from a use of ‘loop’
- In the expression: loop
- In an equation for ‘f’: f = loop
+
+T5236.hs:13:9:
+ Couldn't match type ‘A’ with ‘B’
+ arising from a functional dependency between:
+ constraint ‘Id A B’
+ arising from the type signature for loop :: Id A B => Bool
+ instance ‘Id A A’ at T5236.hs:10:10-15
+ In the ambiguity check for: Id A B => Bool
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature for ‘loop’: loop :: Id A B => Bool
diff --git a/testsuite/tests/typecheck/should_fail/T5978.stderr b/testsuite/tests/typecheck/should_fail/T5978.stderr
index db6b8f355e..263e68ba2d 100644
--- a/testsuite/tests/typecheck/should_fail/T5978.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5978.stderr
@@ -1,5 +1,8 @@
-
-T5978.hs:22:11:
- No instance for (C Double Char) arising from a use of ‘polyBar’
- In the expression: polyBar id monoFoo
- In an equation for ‘monoBar’: monoBar = polyBar id monoFoo
+
+T5978.hs:22:11:
+ Couldn't match type ‘Bool’ with ‘Char’
+ arising from a functional dependency between:
+ constraint ‘C Double Char’ arising from a use of ‘polyBar’
+ instance ‘C Double Bool’ at T5978.hs:8:10-22
+ In the expression: polyBar id monoFoo
+ In an equation for ‘monoBar’: monoBar = polyBar id monoFoo
diff --git a/testsuite/tests/typecheck/should_fail/T9612.hs b/testsuite/tests/typecheck/should_fail/T9612.hs
new file mode 100644
index 0000000000..a332c47b04
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9612.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses #-}
+module T9612 where
+import Data.Monoid
+import Control.Monad.Trans.Writer.Lazy( Writer, WriterT )
+import Data.Functor.Identity( Identity )
+
+class (Monoid w, Monad m) => MonadWriter w m | m -> w where
+ writer :: (a,w) -> m a
+ tell :: w -> m ()
+ listen :: m a -> m (a, w)
+ pass :: m (a, w -> w) -> m a
+
+f ::(Eq a) => a -> (Int, a) -> Writer [(Int, a)] (Int, a)
+f y (n,x) {- | y == x = return (n+1, x)
+ | otherwise = -}
+ = do tell (n,x)
+ return (1,y)
+
+
+instance (Monoid w, Monad m) => MonadWriter w (WriterT w m) where
diff --git a/testsuite/tests/typecheck/should_fail/T9612.stderr b/testsuite/tests/typecheck/should_fail/T9612.stderr
new file mode 100644
index 0000000000..823fee112c
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9612.stderr
@@ -0,0 +1,20 @@
+
+T9612.hs:16:9:
+ Couldn't match type ‘[(Int, a)]’ with ‘(Int, a)’
+ arising from a functional dependency between:
+ constraint ‘MonadWriter (Int, a) (WriterT [(Int, a)] Identity)’
+ arising from a use of ‘tell’
+ instance ‘MonadWriter w (WriterT w m)’ at T9612.hs:20:10-59
+ Relevant bindings include
+ x :: a (bound at T9612.hs:14:8)
+ y :: a (bound at T9612.hs:14:3)
+ f :: a -> (Int, a) -> Writer [(Int, a)] (Int, a)
+ (bound at T9612.hs:14:1)
+ In a stmt of a 'do' block: tell (n, x)
+ In the expression:
+ do { tell (n, x);
+ return (1, y) }
+ In an equation for ‘f’:
+ f y (n, x)
+ = do { tell (n, x);
+ return (1, y) }
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 4f001f5ab7..431a9ba767 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -334,3 +334,4 @@ test('T9196', normal, compile_fail, [''])
test('T9305', normal, compile_fail, [''])
test('T9323', normal, compile_fail, [''])
test('T9415', normal, compile_fail, [''])
+test('T9612', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/tcfail143.stderr b/testsuite/tests/typecheck/should_fail/tcfail143.stderr
index 394fa43c4e..b36d7a8b37 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail143.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail143.stderr
@@ -1,5 +1,8 @@
-
-tcfail143.hs:29:9:
- No instance for (MinMax (S Z) Z Z Z) arising from a use of ‘extend’
- In the expression: n1 `extend` n0
- In an equation for ‘t2’: t2 = n1 `extend` n0
+
+tcfail143.hs:29:9:
+ Couldn't match type ‘S Z’ with ‘Z’
+ arising from a functional dependency between:
+ constraint ‘MinMax (S Z) Z Z Z’ arising from a use of ‘extend’
+ instance ‘MinMax a Z Z a’ at tcfail143.hs:11:10-23
+ In the expression: n1 `extend` n0
+ In an equation for ‘t2’: t2 = n1 `extend` n0