diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-09-21 17:39:18 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-09-25 14:01:15 +0100 |
commit | 1b476ab55be6c2c553988cc63d8e0c5473136275 (patch) | |
tree | 3fcf1a41488ab6354dac819c280539046e763c25 /testsuite/tests | |
parent | 3b4833a22596922d5e7a3f0037c960a5e230fb31 (diff) | |
download | haskell-1b476ab55be6c2c553988cc63d8e0c5473136275.tar.gz |
Improve type-error reporting
This patch does two things:
* When reporting a hole, we now include its kind if the
kind is not just '*'. This addresses Trac #14265
* When reporting things like "'a' is a rigid type varaible
bound by ...", this patch arranges to group the type variables
together, so we don't repeat the "bound by..." stuff endlessly
Diffstat (limited to 'testsuite/tests')
16 files changed, 70 insertions, 66 deletions
diff --git a/testsuite/tests/ghci/scripts/T10248.stderr b/testsuite/tests/ghci/scripts/T10248.stderr index e1ca96c63f..283ccdddc4 100644 --- a/testsuite/tests/ghci/scripts/T10248.stderr +++ b/testsuite/tests/ghci/scripts/T10248.stderr @@ -1,10 +1,7 @@ <interactive>:2:10: error: • Found hole: _ :: f a - Where: ‘f’ is a rigid type variable bound by - the inferred type of it :: Functor f => f (Maybe a) - at <interactive>:2:1-10 - ‘a’ is a rigid type variable bound by + Where: ‘f’, ‘a’ are rigid type variables bound by the inferred type of it :: Functor f => f (Maybe a) at <interactive>:2:1-10 • In the second argument of ‘(<$>)’, namely ‘_’ diff --git a/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr b/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr index 01651a4136..a11164482c 100644 --- a/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr +++ b/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr @@ -1,4 +1,4 @@ SuperCls.hs:4:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘() :: Constraint’ + • Found type wildcard ‘_’ standing for ‘()’ • In the type signature: f :: (Ord a, _) => a -> Bool diff --git a/testsuite/tests/partial-sigs/should_compile/T10403.stderr b/testsuite/tests/partial-sigs/should_compile/T10403.stderr index 6ebd844bff..229b9e1df1 100644 --- a/testsuite/tests/partial-sigs/should_compile/T10403.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T10403.stderr @@ -1,33 +1,26 @@ T10403.hs:15:7: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Functor f’ - Where: ‘f’ is a rigid type variable bound by - the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f + Where: ‘f’ is a rigid type variable + bound by the inferred type of + h1 :: Functor f => (a -> b) -> f a -> H f at T10403.hs:17:1-41 • In the type signature: h1 :: _ => _ T10403.hs:15:12: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘(a -> b) -> f a -> H f’ - Where: ‘b’ is a rigid type variable bound by - the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f - at T10403.hs:17:1-41 - ‘a’ is a rigid type variable bound by - the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f - at T10403.hs:17:1-41 - ‘f’ is a rigid type variable bound by - the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f + Where: ‘b’, ‘a’, ‘f’ are rigid type variables + bound by the inferred type of + h1 :: Functor f => (a -> b) -> f a -> H f at T10403.hs:17:1-41 • In the type signature: h1 :: _ => _ T10403.hs:19:7: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘(a -> b) -> f0 a -> H f0’ - Where: ‘b’ is a rigid type variable bound by - the inferred type of h2 :: (a -> b) -> f0 a -> H f0 - at T10403.hs:22:1-41 - ‘a’ is a rigid type variable bound by - the inferred type of h2 :: (a -> b) -> f0 a -> H f0 + Where: ‘f0’ is an ambiguous type variable + ‘b’, ‘a’ are rigid type variables + bound by the inferred type of h2 :: (a -> b) -> f0 a -> H f0 at T10403.hs:22:1-41 - ‘f0’ is an ambiguous type variable • In the type signature: h2 :: _ T10403.hs:22:15: warning: [-Wdeferred-type-errors (in -Wdefault)] diff --git a/testsuite/tests/partial-sigs/should_compile/T11016.stderr b/testsuite/tests/partial-sigs/should_compile/T11016.stderr index 343deabe86..49363fb24c 100644 --- a/testsuite/tests/partial-sigs/should_compile/T11016.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T11016.stderr @@ -1,6 +1,6 @@ T11016.hs:5:19: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘() :: Constraint’ + • Found type wildcard ‘_’ standing for ‘()’ • In the type signature: f1 :: (?x :: Int, _) => Int T11016.hs:8:22: warning: [-Wpartial-type-signatures (in -Wdefault)] diff --git a/testsuite/tests/partial-sigs/should_compile/T11192.stderr b/testsuite/tests/partial-sigs/should_compile/T11192.stderr index 0f2d2e09b6..8030276206 100644 --- a/testsuite/tests/partial-sigs/should_compile/T11192.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T11192.stderr @@ -2,7 +2,8 @@ T11192.hs:7:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Int -> p -> p’ Where: ‘p’ is a rigid type variable bound by - the inferred type of go :: Int -> p -> p at T11192.hs:8:8-17 + the inferred type of go :: Int -> p -> p + at T11192.hs:8:8-17 • In the type signature: go :: _ In the expression: let @@ -19,10 +20,9 @@ T11192.hs:7:14: warning: [-Wpartial-type-signatures (in -Wdefault)] T11192.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘p -> p1 -> p1’ - Where: ‘p’ is a rigid type variable bound by - the inferred type of go :: p -> p1 -> p1 at T11192.hs:14:8-17 - ‘p1’ is a rigid type variable bound by - the inferred type of go :: p -> p1 -> p1 at T11192.hs:14:8-17 + Where: ‘p’, ‘p1’ are rigid type variables bound by + the inferred type of go :: p -> p1 -> p1 + at T11192.hs:14:8-17 • In the type signature: go :: _ In the expression: let diff --git a/testsuite/tests/partial-sigs/should_compile/T12033.stderr b/testsuite/tests/partial-sigs/should_compile/T12033.stderr index a3b293b0cc..780fb9d41b 100644 --- a/testsuite/tests/partial-sigs/should_compile/T12033.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T12033.stderr @@ -1,15 +1,15 @@ T12033.hs:12:22: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘v -> t’ - Where: ‘v’ is a rigid type variable bound by + Where: ‘t’ is a rigid type variable bound by + the inferred types of + makeTuple :: v -> t + makeExpression :: v -> t + at T12033.hs:(11,4)-(13,39) + ‘v’ is a rigid type variable bound by the type signature for: tripleStoreToRuleSet :: forall v. v -> v at T12033.hs:6:1-30 - ‘t’ is a rigid type variable bound by - the inferred type of - makeTuple :: v -> t - makeExpression :: v -> t - at T12033.hs:(11,4)-(13,39) • In the type signature: makeExpression :: _ In an equation for ‘tripleStoreToRuleSet’: tripleStoreToRuleSet getAtom diff --git a/testsuite/tests/partial-sigs/should_compile/T12844.stderr b/testsuite/tests/partial-sigs/should_compile/T12844.stderr index 8ad3777f2a..3846590890 100644 --- a/testsuite/tests/partial-sigs/should_compile/T12844.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T12844.stderr @@ -2,24 +2,9 @@ T12844.hs:12:9: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘(Head rngs ~ '(r, r'), Foo rngs)’ - Where: ‘r’ is a rigid type variable bound by + Where: ‘r’, ‘r'’, ‘rngs’, ‘k’, ‘k1’ + are rigid type variables bound by the inferred type of - bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs - at T12844.hs:13:1-9 - ‘r'’ is a rigid type variable bound by - the inferred type of - bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs - at T12844.hs:13:1-9 - ‘rngs’ is a rigid type variable bound by - the inferred type of - bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs - at T12844.hs:13:1-9 - ‘k’ is a rigid type variable bound by - the inferred type of - bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs - at T12844.hs:13:1-9 - ‘k1’ is a rigid type variable bound by - the inferred type of - bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs + bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs at T12844.hs:13:1-9 • In the type signature: bar :: _ => FooData rngs diff --git a/testsuite/tests/partial-sigs/should_compile/T12845.stderr b/testsuite/tests/partial-sigs/should_compile/T12845.stderr index b9d7d60a97..a483c84231 100644 --- a/testsuite/tests/partial-sigs/should_compile/T12845.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T12845.stderr @@ -1,6 +1,6 @@ T12845.hs:18:70: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘() :: Constraint’ + • Found type wildcard ‘_’ standing for ‘()’ • In the type signature: broken :: forall r r' rngs. ('(r, r') ~ Head rngs, Bar r r' ~ 'True, _) => diff --git a/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr b/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr index ca815439de..560b74d3b9 100644 --- a/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr +++ b/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr @@ -34,10 +34,7 @@ WarningWildcardInstantiations.hs:8:8: warning: [-Wpartial-type-signatures (in -W WarningWildcardInstantiations.hs:8:13: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘t -> w’ - Where: ‘t’ is a rigid type variable bound by - the inferred type of bar :: t -> (t -> w) -> w - at WarningWildcardInstantiations.hs:9:1-13 - ‘w’ is a rigid type variable bound by + Where: ‘t’, ‘w’ are rigid type variables bound by the inferred type of bar :: t -> (t -> w) -> w at WarningWildcardInstantiations.hs:9:1-13 • In the type signature: bar :: _ -> _ -> _ diff --git a/testsuite/tests/partial-sigs/should_fail/T10045.stderr b/testsuite/tests/partial-sigs/should_fail/T10045.stderr index a18ef48b83..e6f6462d5d 100644 --- a/testsuite/tests/partial-sigs/should_fail/T10045.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T10045.stderr @@ -1,10 +1,9 @@ T10045.hs:6:18: error: • Found type wildcard ‘_’ standing for ‘t1 -> Bool -> t2’ - Where: ‘t1’ is a rigid type variable bound by - the inferred type of copy :: t1 -> Bool -> t2 at T10045.hs:7:10-34 - ‘t2’ is a rigid type variable bound by - the inferred type of copy :: t1 -> Bool -> t2 at T10045.hs:7:10-34 + Where: ‘t1’, ‘t2’ are rigid type variables bound by + the inferred type of copy :: t1 -> Bool -> t2 + at T10045.hs:7:10-34 To use the inferred type, enable PartialTypeSignatures • In the type signature: copy :: _ In the expression: diff --git a/testsuite/tests/partial-sigs/should_fail/T12634.stderr b/testsuite/tests/partial-sigs/should_fail/T12634.stderr index 7f1d713c4f..dd661a9355 100644 --- a/testsuite/tests/partial-sigs/should_fail/T12634.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T12634.stderr @@ -1,6 +1,6 @@ T12634.hs:14:37: error: - • Found type wildcard ‘_’ standing for ‘() :: Constraint’ + • Found type wildcard ‘_’ standing for ‘()’ To use the inferred type, enable PartialTypeSignatures • In the type signature: bench_twacePow :: forall t m m' r. diff --git a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr index 440d8722de..aa5e8247f3 100644 --- a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr +++ b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr @@ -30,10 +30,7 @@ WildcardInstantiations.hs:8:8: error: WildcardInstantiations.hs:8:13: error: • Found type wildcard ‘_’ standing for ‘t -> w’ - Where: ‘t’ is a rigid type variable bound by - the inferred type of bar :: t -> (t -> w) -> w - at WildcardInstantiations.hs:9:1-13 - ‘w’ is a rigid type variable bound by + Where: ‘t’, ‘w’ are rigid type variables bound by the inferred type of bar :: t -> (t -> w) -> w at WildcardInstantiations.hs:9:1-13 To use the inferred type, enable PartialTypeSignatures diff --git a/testsuite/tests/perf/compiler/T13035.stderr b/testsuite/tests/perf/compiler/T13035.stderr index 52836d7e3c..fe1f0b2564 100644 --- a/testsuite/tests/perf/compiler/T13035.stderr +++ b/testsuite/tests/perf/compiler/T13035.stderr @@ -1,4 +1,4 @@ T13035.hs:141:28: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘'['Author]’ + • Found type wildcard ‘_’ standing for ‘'['Author] :: [Fields]’ • In the type signature: g :: MyRec RecipeFormatter _ diff --git a/testsuite/tests/polykinds/T14265.hs b/testsuite/tests/polykinds/T14265.hs new file mode 100644 index 0000000000..84c1a025a1 --- /dev/null +++ b/testsuite/tests/polykinds/T14265.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds #-} + +module T124265 where + +import Control.Monad.Trans.State( StateT ) + +f :: proxy _ -> () +f _ = () + +foo :: StateT _ _ () +foo = undefined diff --git a/testsuite/tests/polykinds/T14265.stderr b/testsuite/tests/polykinds/T14265.stderr new file mode 100644 index 0000000000..be6868fdc4 --- /dev/null +++ b/testsuite/tests/polykinds/T14265.stderr @@ -0,0 +1,24 @@ + +T14265.hs:7:12: error: + • Found type wildcard ‘_’ standing for ‘w :: k’ + Where: ‘w’, ‘k’ are rigid type variables bound by + the inferred type of f :: proxy w -> () + at T14265.hs:8:1-8 + To use the inferred type, enable PartialTypeSignatures + • In the type signature: f :: proxy _ -> () + +T14265.hs:10:15: error: + • Found type wildcard ‘_’ standing for ‘w’ + Where: ‘w’ is a rigid type variable bound by + the inferred type of foo :: StateT w w1 () + at T14265.hs:11:1-15 + To use the inferred type, enable PartialTypeSignatures + • In the type signature: foo :: StateT _ _ () + +T14265.hs:10:17: error: + • Found type wildcard ‘_’ standing for ‘w1 :: * -> *’ + Where: ‘w1’ is a rigid type variable bound by + the inferred type of foo :: StateT w w1 () + at T14265.hs:11:1-15 + To use the inferred type, enable PartialTypeSignatures + • In the type signature: foo :: StateT _ _ () diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index c01b73c98d..78c16975da 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -168,3 +168,4 @@ test('T14110', normal, compile_fail, ['']) test('BadKindVar', normal, compile_fail, ['']) test('T13738', normal, compile_fail, ['']) test('T14209', normal, compile, ['']) +test('T14265', normal, compile_fail, ['']) |