summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-04-25 00:04:45 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-04-28 10:59:51 +0100
commitba2e20149e2addaccf5ce3122d3a6e93da696a0a (patch)
tree14d2eb5a30ccb5f98be00caae683393e98d19979 /testsuite/tests/typecheck
parent0960a37868e6d08857e86465c8ca346b29b1c813 (diff)
downloadhaskell-ba2e20149e2addaccf5ce3122d3a6e93da696a0a.tar.gz
Do type-class defaulting even if there are insoluble constraints
The argument in Trac #9033 is very compelling: we should not report 20 errors, fix one, and have the other 19 disappear. They were spurious in the first place. The fix was easy; do type-class defaulting uncondionally, rather than only if there are no insoluble constraints. See Note [When to do type-class defaulting] in TcSimplify. Error messages generally improve, especially tc211 which actually had an example of precisely this phenomenon.
Diffstat (limited to 'testsuite/tests/typecheck')
-rw-r--r--testsuite/tests/typecheck/should_compile/tc211.stderr107
-rw-r--r--testsuite/tests/typecheck/should_fail/T8603.stderr8
-rw-r--r--testsuite/tests/typecheck/should_fail/T9033.hs7
-rw-r--r--testsuite/tests/typecheck/should_fail/T9033.stderr5
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/mc24.stderr16
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail004.stderr18
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail005.stderr17
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail140.stderr76
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail189.stderr16
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail206.stderr9
11 files changed, 119 insertions, 161 deletions
diff --git a/testsuite/tests/typecheck/should_compile/tc211.stderr b/testsuite/tests/typecheck/should_compile/tc211.stderr
index bdc5bd1879..533155a657 100644
--- a/testsuite/tests/typecheck/should_compile/tc211.stderr
+++ b/testsuite/tests/typecheck/should_compile/tc211.stderr
@@ -1,82 +1,25 @@
-
-tc211.hs:15:22:
- Couldn't match type ‘forall a6. a6 -> a6’ with ‘a -> a’
- Expected type: [a -> a]
- Actual type: [forall a. a -> a]
- In the first argument of ‘head’, namely ‘foo’
- In the first argument of ‘(:) ::
- (forall a. a -> a)
- -> [forall a. a -> a] -> [forall a. a -> a]’, namely
- ‘(head foo)’
-
-tc211.hs:48:19:
- Could not deduce (Num a2) arising from the literal ‘3’
- from the context (Num a)
- bound by the inferred type of
- h1 :: Num a => (forall a1. a1 -> a1) -> a
- at tc211.hs:(47,1)-(49,9)
- The type variable ‘a2’ is ambiguous
- Relevant bindings include
- y :: Pair a2 (Pair a3 b1) (bound at tc211.hs:48:10)
- Note: there are several potential instances:
- instance Num Double -- Defined in ‘GHC.Float’
- instance Num Float -- Defined in ‘GHC.Float’
- instance Integral a => Num (GHC.Real.Ratio a)
- -- Defined in ‘GHC.Real’
- ...plus three others
- In the first argument of ‘g’, namely ‘3’
- In the first argument of ‘P’, namely ‘(g 3)’
- In the expression: P (g 3) (g (P 3 4))
-
-tc211.hs:48:28:
- Could not deduce (Num a3) arising from the literal ‘3’
- from the context (Num a)
- bound by the inferred type of
- h1 :: Num a => (forall a1. a1 -> a1) -> a
- at tc211.hs:(47,1)-(49,9)
- The type variable ‘a3’ is ambiguous
- Relevant bindings include
- y :: Pair a2 (Pair a3 b1) (bound at tc211.hs:48:10)
- Note: there are several potential instances:
- instance Num Double -- Defined in ‘GHC.Float’
- instance Num Float -- Defined in ‘GHC.Float’
- instance Integral a => Num (GHC.Real.Ratio a)
- -- Defined in ‘GHC.Real’
- ...plus three others
- In the first argument of ‘P’, namely ‘3’
- In the first argument of ‘g’, namely ‘(P 3 4)’
- In the second argument of ‘P’, namely ‘(g (P 3 4))’
-
-tc211.hs:48:30:
- Could not deduce (Num b1) arising from the literal ‘4’
- from the context (Num a)
- bound by the inferred type of
- h1 :: Num a => (forall a1. a1 -> a1) -> a
- at tc211.hs:(47,1)-(49,9)
- The type variable ‘b1’ is ambiguous
- Relevant bindings include
- y :: Pair a2 (Pair a3 b1) (bound at tc211.hs:48:10)
- Note: there are several potential instances:
- instance Num Double -- Defined in ‘GHC.Float’
- instance Num Float -- Defined in ‘GHC.Float’
- instance Integral a => Num (GHC.Real.Ratio a)
- -- Defined in ‘GHC.Real’
- ...plus three others
- In the second argument of ‘P’, namely ‘4’
- In the first argument of ‘g’, namely ‘(P 3 4)’
- In the second argument of ‘P’, namely ‘(g (P 3 4))’
-
-tc211.hs:70:9:
- Couldn't match type ‘forall a7. a7 -> a7’ with ‘a6 -> a6’
- Expected type: List (forall a. a -> a)
- -> (forall a. a -> a) -> a6 -> a6
- Actual type: List (forall a. a -> a)
- -> (forall a. a -> a) -> forall a. a -> a
- In the expression:
- foo2 ::
- List (forall a. a -> a) -> (forall a. a -> a) -> (forall a. a -> a)
- In the expression:
- (foo2 ::
- List (forall a. a -> a)
- -> (forall a. a -> a) -> (forall a. a -> a))
- xs1 (\ x -> x)
+
+tc211.hs:15:22:
+ Couldn't match type ‘forall a1. a1 -> a1’ with ‘a -> a’
+ Expected type: [a -> a]
+ Actual type: [forall a. a -> a]
+ In the first argument of ‘head’, namely ‘foo’
+ In the first argument of ‘(:) ::
+ (forall a. a -> a)
+ -> [forall a. a -> a] -> [forall a. a -> a]’, namely
+ ‘(head foo)’
+
+tc211.hs:70:9:
+ Couldn't match type ‘forall a2. a2 -> a2’ with ‘a1 -> a1’
+ Expected type: List (forall a. a -> a)
+ -> (forall a. a -> a) -> a1 -> a1
+ Actual type: List (forall a. a -> a)
+ -> (forall a. a -> a) -> forall a. a -> a
+ In the expression:
+ foo2 ::
+ List (forall a. a -> a) -> (forall a. a -> a) -> (forall a. a -> a)
+ In the expression:
+ (foo2 ::
+ List (forall a. a -> a)
+ -> (forall a. a -> a) -> (forall a. a -> a))
+ xs1 (\ x -> x)
diff --git a/testsuite/tests/typecheck/should_fail/T8603.stderr b/testsuite/tests/typecheck/should_fail/T8603.stderr
index cf12725281..8ee8cccb4a 100644
--- a/testsuite/tests/typecheck/should_fail/T8603.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8603.stderr
@@ -1,11 +1,11 @@
T8603.hs:29:17:
- Couldn't match type ‘(->) [a0]’ with ‘[t1]’
- Expected type: [t1] -> StateT s RV t0
- Actual type: t2 ((->) [a0]) (StateT s RV t0)
+ Couldn't match type ‘(->) [a0]’ with ‘[Integer]’
+ Expected type: [Integer] -> StateT s RV t0
+ Actual type: t1 ((->) [a0]) (StateT s RV t0)
The function ‘lift’ is applied to two arguments,
but its type ‘([a0] -> StateT s RV t0)
- -> t2 ((->) [a0]) (StateT s RV t0)’
+ -> t1 ((->) [a0]) (StateT s RV t0)’
has only one
In a stmt of a 'do' block: prize <- lift uniform [1, 2, 3]
In the expression:
diff --git a/testsuite/tests/typecheck/should_fail/T9033.hs b/testsuite/tests/typecheck/should_fail/T9033.hs
new file mode 100644
index 0000000000..cc9277fc17
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9033.hs
@@ -0,0 +1,7 @@
+module T9030 where
+
+bad :: Bool
+bad = ()
+
+square :: Integral i => i -> i
+square x = x^2
diff --git a/testsuite/tests/typecheck/should_fail/T9033.stderr b/testsuite/tests/typecheck/should_fail/T9033.stderr
new file mode 100644
index 0000000000..c2fd563124
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9033.stderr
@@ -0,0 +1,5 @@
+
+T9033.hs:4:7:
+ Couldn't match expected type ‘Bool’ with actual type ‘()’
+ In the expression: ()
+ In an equation for ‘bad’: bad = ()
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 2407af51be..fe15e983e2 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -331,3 +331,4 @@ test('T8570', extra_clean(['T85570a.o', 'T8570a.hi','T85570b.o', 'T8570b.hi']),
test('T8603', normal, compile_fail, [''])
test('T8806', normal, compile_fail, [''])
test('T8912', normal, compile_fail, [''])
+test('T9033', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/mc24.stderr b/testsuite/tests/typecheck/should_fail/mc24.stderr
index 0ddc66d97a..495693c9f8 100644
--- a/testsuite/tests/typecheck/should_fail/mc24.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc24.stderr
@@ -1,8 +1,8 @@
-
-mc24.hs:10:31:
- Couldn't match type ‘[a0]’ with ‘a -> a1’
- Expected type: (a -> a1) -> [a] -> t [a]
- Actual type: [a0] -> [a0]
- Possible cause: ‘take’ is applied to too many arguments
- In the expression: take 2
- In a stmt of a monad comprehension: then group by x using take 2
+
+mc24.hs:10:31:
+ Couldn't match type ‘[a0]’ with ‘a -> Integer’
+ Expected type: (a -> Integer) -> [a] -> t [a]
+ Actual type: [a0] -> [a0]
+ Possible cause: ‘take’ is applied to too many arguments
+ In the expression: take 2
+ In a stmt of a monad comprehension: then group by x using take 2
diff --git a/testsuite/tests/typecheck/should_fail/tcfail004.stderr b/testsuite/tests/typecheck/should_fail/tcfail004.stderr
index df54f950c6..48840e7298 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail004.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail004.stderr
@@ -1,9 +1,9 @@
-
-tcfail004.hs:3:9:
- Couldn't match expected type ‘(t, t3)’
- with actual type ‘(t0, t1, t2)’
- Relevant bindings include
- f :: t (bound at tcfail004.hs:3:2)
- g :: t3 (bound at tcfail004.hs:3:4)
- In the expression: (1, 2, 3)
- In a pattern binding: (f, g) = (1, 2, 3)
+
+tcfail004.hs:3:9:
+ Couldn't match expected type ‘(t, t1)’
+ with actual type ‘(Integer, Integer, Integer)’
+ Relevant bindings include
+ f :: t (bound at tcfail004.hs:3:2)
+ g :: t1 (bound at tcfail004.hs:3:4)
+ In the expression: (1, 2, 3)
+ In a pattern binding: (f, g) = (1, 2, 3)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail005.stderr b/testsuite/tests/typecheck/should_fail/tcfail005.stderr
index bae8697fe8..36f0e738e4 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail005.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail005.stderr
@@ -1,8 +1,9 @@
-
-tcfail005.hs:3:9:
- Couldn't match expected type ‘[t]’ with actual type ‘(t0, Char)’
- Relevant bindings include
- h :: t (bound at tcfail005.hs:3:2)
- i :: [t] (bound at tcfail005.hs:3:4)
- In the expression: (1, 'a')
- In a pattern binding: (h : i) = (1, 'a')
+
+tcfail005.hs:3:9:
+ Couldn't match expected type ‘[t]’
+ with actual type ‘(Integer, Char)’
+ Relevant bindings include
+ h :: t (bound at tcfail005.hs:3:2)
+ i :: [t] (bound at tcfail005.hs:3:4)
+ In the expression: (1, 'a')
+ In a pattern binding: (h : i) = (1, 'a')
diff --git a/testsuite/tests/typecheck/should_fail/tcfail140.stderr b/testsuite/tests/typecheck/should_fail/tcfail140.stderr
index bb45df3dee..7593497fe2 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail140.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail140.stderr
@@ -1,38 +1,38 @@
-
-tcfail140.hs:10:7:
- Couldn't match expected type ‘a0 -> t’ with actual type ‘Int’
- Relevant bindings include bar :: t (bound at tcfail140.hs:10:1)
- The function ‘f’ is applied to two arguments,
- but its type ‘Int -> Int’ has only one
- In the expression: f 3 9
- In an equation for ‘bar’: bar = f 3 9
-
-tcfail140.hs:12:10:
- Couldn't match expected type ‘a1 -> t1’ with actual type ‘Int’
- Relevant bindings include
- rot :: t -> t1 (bound at tcfail140.hs:12:1)
- The operator ‘f’ takes two arguments,
- but its type ‘Int -> Int’ has only one
- In the expression: 3 `f` 4
- In an equation for ‘rot’: rot xs = 3 `f` 4
-
-tcfail140.hs:14:15:
- Couldn't match expected type ‘a -> b’ with actual type ‘Int’
- Relevant bindings include
- xs :: [a] (bound at tcfail140.hs:14:5)
- bot :: [a] -> [b] (bound at tcfail140.hs:14:1)
- The operator ‘f’ takes two arguments,
- but its type ‘Int -> Int’ has only one
- In the first argument of ‘map’, namely ‘(3 `f`)’
- In the expression: map (3 `f`) xs
-
-tcfail140.hs:16:8:
- Constructor ‘Just’ should have 1 argument, but has been given none
- In the pattern: Just
- In the expression: (\ Just x -> x) :: Maybe a -> a
- In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1)
-
-tcfail140.hs:19:1:
- Couldn't match expected type ‘t0 -> Bool’ with actual type ‘Int’
- The equation(s) for ‘g’ have two arguments,
- but its type ‘Int -> Int’ has only one
+
+tcfail140.hs:10:7:
+ Couldn't match expected type ‘Integer -> t’ with actual type ‘Int’
+ Relevant bindings include bar :: t (bound at tcfail140.hs:10:1)
+ The function ‘f’ is applied to two arguments,
+ but its type ‘Int -> Int’ has only one
+ In the expression: f 3 9
+ In an equation for ‘bar’: bar = f 3 9
+
+tcfail140.hs:12:10:
+ Couldn't match expected type ‘Integer -> t1’ with actual type ‘Int’
+ Relevant bindings include
+ rot :: t -> t1 (bound at tcfail140.hs:12:1)
+ The operator ‘f’ takes two arguments,
+ but its type ‘Int -> Int’ has only one
+ In the expression: 3 `f` 4
+ In an equation for ‘rot’: rot xs = 3 `f` 4
+
+tcfail140.hs:14:15:
+ Couldn't match expected type ‘a -> b’ with actual type ‘Int’
+ Relevant bindings include
+ xs :: [a] (bound at tcfail140.hs:14:5)
+ bot :: [a] -> [b] (bound at tcfail140.hs:14:1)
+ The operator ‘f’ takes two arguments,
+ but its type ‘Int -> Int’ has only one
+ In the first argument of ‘map’, namely ‘(3 `f`)’
+ In the expression: map (3 `f`) xs
+
+tcfail140.hs:16:8:
+ Constructor ‘Just’ should have 1 argument, but has been given none
+ In the pattern: Just
+ In the expression: (\ Just x -> x) :: Maybe a -> a
+ In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1)
+
+tcfail140.hs:19:1:
+ Couldn't match expected type ‘t0 -> Bool’ with actual type ‘Int’
+ The equation(s) for ‘g’ have two arguments,
+ but its type ‘Int -> Int’ has only one
diff --git a/testsuite/tests/typecheck/should_fail/tcfail189.stderr b/testsuite/tests/typecheck/should_fail/tcfail189.stderr
index 69e8b3dbba..6bd08a266c 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail189.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail189.stderr
@@ -1,8 +1,8 @@
-
-tcfail189.hs:10:31:
- Couldn't match type ‘[a0]’ with ‘a -> a1’
- Expected type: (a -> a1) -> [a] -> [[a]]
- Actual type: [a0] -> [a0]
- Possible cause: ‘take’ is applied to too many arguments
- In the expression: take 2
- In a stmt of a list comprehension: then group by x using take 2
+
+tcfail189.hs:10:31:
+ Couldn't match type ‘[a0]’ with ‘a -> Integer’
+ Expected type: (a -> Integer) -> [a] -> [[a]]
+ Actual type: [a0] -> [a0]
+ Possible cause: ‘take’ is applied to too many arguments
+ In the expression: take 2
+ In a stmt of a list comprehension: then group by x using take 2
diff --git a/testsuite/tests/typecheck/should_fail/tcfail206.stderr b/testsuite/tests/typecheck/should_fail/tcfail206.stderr
index 4fe402982a..3eec7088cd 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail206.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail206.stderr
@@ -7,9 +7,9 @@ tcfail206.hs:5:5:
In an equation for ‘a’: a = (, True)
tcfail206.hs:8:5:
- Couldn't match type ‘(t0, Int)’ with ‘Bool -> (Int, Bool)’
+ Couldn't match type ‘(Integer, Int)’ with ‘Bool -> (Int, Bool)’
Expected type: Int -> Bool -> (Int, Bool)
- Actual type: Int -> (t0, Int)
+ Actual type: Int -> (Integer, Int)
In the expression: (1,)
In an equation for ‘b’: b = (1,)
@@ -32,9 +32,10 @@ tcfail206.hs:14:5:
In an equation for ‘d’: d = (# , True #)
tcfail206.hs:17:5:
- Couldn't match type ‘(# a0, Int #)’ with ‘Bool -> (# Int, Bool #)’
+ Couldn't match type ‘(# Integer, Int #)’
+ with ‘Bool -> (# Int, Bool #)’
Expected type: Int -> Bool -> (# Int, Bool #)
- Actual type: Int -> (# a0, Int #)
+ Actual type: Int -> (# Integer, Int #)
In the expression: (# 1, #)
In an equation for ‘e’: e = (# 1, #)