Skip to content
Snippets Groups Projects
Commit 549292eb authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

Make implication tidying agree with Note [Tidying multiple names at once]

Note [Tidying multiple names at once] indicates that if multiple
variables have the same name then we shouldn't prioritise one of them
and instead rename them all to a1, a2, a3... etc

This patch implements that change, some error message changes as
expected.

Closes #20932
parent 299acff0
No related branches found
No related tags found
No related merge requests found
Showing
with 121 additions and 121 deletions
......@@ -82,7 +82,7 @@ import Control.Monad ( unless, when, foldM, forM_ )
import Data.Foldable ( toList )
import Data.Functor ( (<&>) )
import Data.Function ( on )
import Data.List ( partition, mapAccumL, sort )
import Data.List ( partition, sort )
import Data.List.NonEmpty ( NonEmpty(..), (<|) )
import qualified Data.List.NonEmpty as NE ( map, reverse )
import Data.List ( sortBy )
......@@ -357,7 +357,7 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs
warnRedundantConstraints ctxt' tcl_env info' dead_givens }
where
insoluble = isInsolubleStatus status
(env1, tvs') = mapAccumL tidyVarBndr (cec_tidy ctxt) $
(env1, tvs') = tidyVarBndrs (cec_tidy ctxt) $
scopedSort tvs
-- scopedSort: the ic_skols may not be in dependency order
-- (see Note [Skolems in an implication] in GHC.Tc.Types.Constraint)
......
T14066e.hs:13:65: error:
• Expected a type, but ‘c'’ has kind ‘k’
‘k’ is a rigid type variable bound by
• Expected a type, but ‘c'’ has kind ‘k1
‘k1’ is a rigid type variable bound by
the type signature for:
j :: forall {k} {k1} (c :: k) (b :: k1).
j :: forall {k1} {k2} (c :: k1) (b :: k2).
Proxy a -> Proxy b -> Proxy c -> Proxy b
at T14066e.hs:12:5-61
• In the kind ‘c'’
......
......@@ -6,13 +6,13 @@ deriving-via-fail4.hs:15:12: error:
• When deriving the instance for (Eq F1)
deriving-via-fail4.hs:18:13: error:
• Couldn't match representation of type ‘a’ with that of ‘a1
• Couldn't match representation of type ‘a1’ with that of ‘a2
arising from the coercion of the method ‘c’
from type ‘a -> a -> Bool’ to type ‘a -> F2 a1 -> Bool’
‘a’ is a rigid type variable bound by
‘a1’ is a rigid type variable bound by
the deriving clause for ‘C a (F2 a1)’
at deriving-via-fail4.hs:18:13-15
‘a1’ is a rigid type variable bound by
‘a2’ is a rigid type variable bound by
the deriving clause for ‘C a (F2 a1)’
at deriving-via-fail4.hs:18:13-15
• When deriving the instance for (C a (F2 a1))
gadt7.hs:16:38: error:
• Could not deduce (p ~ p1)
• Could not deduce (p1 ~ p2)
from the context: a ~ Int
bound by a pattern with constructor: K :: T Int,
in a case alternative
at gadt7.hs:16:33
‘p’ is a rigid type variable bound by
the inferred type of i1b :: T a -> p -> p1
at gadt7.hs:16:1-44
‘p1’ is a rigid type variable bound by
the inferred type of i1b :: T a -> p -> p1
the inferred type of i1b :: T a -> p1 -> p2
at gadt7.hs:16:1-44
‘p2’ is a rigid type variable bound by
the inferred type of i1b :: T a -> p1 -> p2
at gadt7.hs:16:1-44
• In the expression: y1
In a case alternative: K -> y1
In the expression: case t1 of K -> y1
• Relevant bindings include
y1 :: p (bound at gadt7.hs:16:16)
y :: p (bound at gadt7.hs:16:7)
i1b :: T a -> p -> p1 (bound at gadt7.hs:16:1)
y1 :: p1 (bound at gadt7.hs:16:16)
y :: p1 (bound at gadt7.hs:16:7)
i1b :: T a -> p1 -> p2 (bound at gadt7.hs:16:1)
Suggested fix: Consider giving ‘i1b’ a type signature
T14369.hs:29:5: error:
• Couldn't match type ‘a’ with ‘a1
Expected: Sing x -> Maybe (Demote a1)
Actual: Sing x -> Demote (Maybe a)
‘a’ is a rigid type variable bound by
• Couldn't match type ‘a1’ with ‘a2
Expected: Sing x -> Maybe (Demote a2)
Actual: Sing x -> Demote (Maybe a1)
‘a1’ is a rigid type variable bound by
the type signature for:
f :: forall {a} (x :: forall a1. Maybe a1) a1.
SingKind a1 =>
Sing x -> Maybe (Demote a1)
f :: forall {a1} (x :: forall a2. Maybe a2) a2.
SingKind a2 =>
Sing x -> Maybe (Demote a2)
at T14369.hs:28:1-80
‘a1’ is a rigid type variable bound by
‘a2’ is a rigid type variable bound by
the type signature for:
f :: forall {a} (x :: forall a1. Maybe a1) a1.
SingKind a1 =>
Sing x -> Maybe (Demote a1)
f :: forall {a1} (x :: forall a2. Maybe a2) a2.
SingKind a2 =>
Sing x -> Maybe (Demote a2)
at T14369.hs:28:1-80
• In the expression: fromSing
In an equation for ‘f’: f = fromSing
• Relevant bindings include
f :: Sing x -> Maybe (Demote a1) (bound at T14369.hs:29:1)
f :: Sing x -> Maybe (Demote a2) (bound at T14369.hs:29:1)
......@@ -18,10 +18,10 @@ T8518.hs:14:18: error:
callCont :: c -> Z c -> B c -> Maybe (F c) (bound at T8518.hs:14:1)
T8518.hs:16:9: error:
• Couldn't match type: F t1
with: Z t1 -> B t1 -> F t1
Expected: t -> t1 -> F t1
Actual: t -> t1 -> Z t1 -> B t1 -> F t1
• Couldn't match type: F t2
with: Z t2 -> B t2 -> F t2
Expected: t1 -> t2 -> F t2
Actual: t1 -> t2 -> Z t2 -> B t2 -> F t2
• In an equation for ‘callCont’:
callCont c z b
= rpt (4 :: Int) c z b
......@@ -29,4 +29,4 @@ T8518.hs:16:9: error:
rpt 0 c' z' b' = fromJust (fst <$> (continue c' z' b'))
rpt i c' z' b' = let ... in rpt (i - 1) c''
• Relevant bindings include
rpt :: t -> t1 -> F t1 (bound at T8518.hs:16:9)
rpt :: t1 -> t2 -> F t2 (bound at T8518.hs:16:9)
mod71.hs:4:9: error:
• Found hole: _ :: t1
Where: ‘t1’ is a rigid type variable bound by
the inferred type of f :: Num t => (t1 -> t -> t2) -> t2
• Found hole: _ :: t2
Where: ‘t2’ is a rigid type variable bound by
the inferred type of f :: Num t1 => (t2 -> t1 -> t3) -> t3
at mod71.hs:4:1-11
• In the first argument of ‘x’, namely ‘_’
In the expression: x _ 1
In an equation for ‘f’: f x = x _ 1
• Relevant bindings include
x :: t1 -> t -> t2 (bound at mod71.hs:4:3)
f :: (t1 -> t -> t2) -> t2 (bound at mod71.hs:4:1)
Constraints include Num t (from mod71.hs:4:1-11)
x :: t2 -> t1 -> t3 (bound at mod71.hs:4:3)
f :: (t2 -> t1 -> t3) -> t3 (bound at mod71.hs:4:1)
Constraints include Num t1 (from mod71.hs:4:1-11)
mod72.hs:3:7: error: Variable not in scope: g :: t -> t1
mod72.hs:3:7: error: Variable not in scope: g :: t1 -> t2
readFail003.hs:4:27: error:
• Couldn't match expected type ‘(a, [a1], [a2])’
with actual type ‘a’
‘a’ is a rigid type variable bound by
• Couldn't match expected type ‘(a1, [a2], [a3])’
with actual type ‘a1
‘a1’ is a rigid type variable bound by
the inferred types of
a :: a
b :: [a1]
c :: [a2]
a :: a1
b :: [a2]
c :: [a3]
at readFail003.hs:(4,1)-(8,26)
• In the expression: a
In a pattern binding:
......@@ -17,6 +17,6 @@ readFail003.hs:4:27: error:
where
nullity = null
• Relevant bindings include
a :: a (bound at readFail003.hs:4:3)
b :: [a1] (bound at readFail003.hs:4:5)
c :: [a2] (bound at readFail003.hs:4:7)
a :: a1 (bound at readFail003.hs:4:3)
b :: [a2] (bound at readFail003.hs:4:5)
c :: [a3] (bound at readFail003.hs:4:7)
......@@ -2,23 +2,23 @@
T10403.hs:16:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found extra-constraints wildcard standing for ‘Functor f’
Where: ‘f’ is a rigid type variable bound by
the inferred type of h1 :: Functor f => (a -> a1) -> f a -> H f
the inferred type of h1 :: Functor f => (a1 -> a2) -> f a1 -> H f
at T10403.hs:18:1-41
• In the type signature: h1 :: _ => _
T10403.hs:16:12: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’ standing for ‘(a -> a1) -> f a -> H f’
Where: ‘a1’, ‘a’, ‘f’ are rigid type variables bound by
the inferred type of h1 :: Functor f => (a -> a1) -> f a -> H f
• Found type wildcard ‘_’ standing for ‘(a1 -> a2) -> f a1 -> H f’
Where: ‘a2’, ‘a1’, ‘f’ are rigid type variables bound by
the inferred type of h1 :: Functor f => (a1 -> a2) -> f a1 -> H f
at T10403.hs:18:1-41
• In the type signature: h1 :: _ => _
T10403.hs:20:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’
standing for ‘(a -> a1) -> B t0 a -> H (B t0)’
standing for ‘(a1 -> a2) -> B t0 a1 -> H (B t0)’
Where: ‘t0’ is an ambiguous type variable
‘a1’, ‘a’ are rigid type variables bound by
the inferred type of h2 :: (a -> a1) -> B t0 a -> H (B t0)
‘a2’, ‘a1’ are rigid type variables bound by
the inferred type of h2 :: (a1 -> a2) -> B t0 a1 -> H (B t0)
at T10403.hs:23:1-41
• In the type signature: h2 :: _
......@@ -26,11 +26,11 @@ T10403.hs:29:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Couldn't match type ‘t0’ with ‘t’
Expected: H (B t)
Actual: H (B t0)
because type variable ‘t’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
app2 :: forall t. H (B t)
at T10403.hs:28:1-15
because type variable ‘t’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
app2 :: forall t. H (B t)
at T10403.hs:28:1-15
• In the expression: h2 (H . I) (B ())
In an equation for ‘app2’: app2 = h2 (H . I) (B ())
• Relevant bindings include
......
T10438.hs:7:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’ standing for ‘p2
Where: ‘p2’ is a rigid type variable bound by
the inferred type of g :: p2 -> p2
• Found type wildcard ‘_’ standing for ‘p3
Where: ‘p3’ is a rigid type variable bound by
the inferred type of g :: p3 -> p3
at T10438.hs:(6,9)-(8,21)
• In the type signature: x :: _
In an equation for ‘g’:
......@@ -21,7 +21,7 @@ T10438.hs:7:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
x :: _
x = r
• Relevant bindings include
r :: p2 (bound at T10438.hs:6:11)
g :: p2 -> p2 (bound at T10438.hs:6:9)
f :: p (bound at T10438.hs:5:5)
foo :: p -> p1 -> p1 (bound at T10438.hs:5:1)
r :: p3 (bound at T10438.hs:6:11)
g :: p3 -> p3 (bound at T10438.hs:6:9)
f :: p1 (bound at T10438.hs:5:5)
foo :: p1 -> p2 -> p2 (bound at T10438.hs:5:1)
......@@ -19,9 +19,9 @@ T11192.hs:7:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Relevant bindings include fails :: a (bound at T11192.hs:6:1)
T11192.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’ standing for ‘p -> p1 -> p1
Where: ‘p’, ‘p1’ are rigid type variables bound by
the inferred type of go :: p -> p1 -> p1
• Found type wildcard ‘_’ standing for ‘p1 -> p2 -> p2
Where: ‘p1’, ‘p2’ are rigid type variables bound by
the inferred type of go :: p1 -> p2 -> p2
at T11192.hs:14:8-17
• In the type signature: go :: _
In the expression:
......
......@@ -2,7 +2,7 @@
T12844.hs:12:9: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found extra-constraints wildcard standing for
‘(Head rngs ~ '(r, r'), Foo rngs)’
Where: ‘r’, ‘r'’, ‘k’, ‘k1’, ‘rngs’
Where: ‘r’, ‘r'’, ‘k1’, ‘k2’, ‘rngs’
are rigid type variables bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
......
TidyClash.hs:8:19: error:
• Found type wildcard ‘_’ standing for ‘w’
Where: ‘w’ is a rigid type variable bound by
the inferred type of bar :: w_ -> (w_, w -> w1)
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of bar :: w_ -> (w_, w1 -> w2)
at TidyClash.hs:9:1-28
To use the inferred type, enable PartialTypeSignatures
• In the type ‘w_ -> (w_, _ -> _)’
In the type signature: bar :: w_ -> (w_, _ -> _)
TidyClash.hs:8:24: error:
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of bar :: w_ -> (w_, w -> w1)
• Found type wildcard ‘_’ standing for ‘w2
Where: ‘w2’ is a rigid type variable bound by
the inferred type of bar :: w_ -> (w_, w1 -> w2)
at TidyClash.hs:9:1-28
To use the inferred type, enable PartialTypeSignatures
• In the type ‘w_ -> (w_, _ -> _)’
......
TidyClash2.hs:13:20: error:
• Found type wildcard ‘_’ standing for ‘w’
Where: ‘w’ is a rigid type variable bound by
the inferred type of barry :: w -> w1 -> t
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of barry :: w1 -> w2 -> t
at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In the type ‘_ -> _ -> t’
In the type signature: barry :: forall t. _ -> _ -> t
TidyClash2.hs:13:25: error:
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of barry :: w -> w1 -> t
• Found type wildcard ‘_’ standing for ‘w2
Where: ‘w2’ is a rigid type variable bound by
the inferred type of barry :: w1 -> w2 -> t
at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In the type ‘_ -> _ -> t’
In the type signature: barry :: forall t. _ -> _ -> t
TidyClash2.hs:14:13: error:
• Found type wildcard ‘_’ standing for ‘w’
Where: ‘w’ is a rigid type variable bound by
the inferred type of barry :: w -> w1 -> t
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of barry :: w1 -> w2 -> t
at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In a pattern type signature: _
......@@ -28,12 +28,12 @@ TidyClash2.hs:14:13: error:
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
barry :: w -> w1 -> t (bound at TidyClash2.hs:14:1)
barry :: w1 -> w2 -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:14:22: error:
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of barry :: w -> w1 -> t
• Found type wildcard ‘_’ standing for ‘w2
Where: ‘w2’ is a rigid type variable bound by
the inferred type of barry :: w1 -> w2 -> t
at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In a pattern type signature: _
......@@ -41,13 +41,13 @@ TidyClash2.hs:14:22: error:
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
x :: w (bound at TidyClash2.hs:14:8)
barry :: w -> w1 -> t (bound at TidyClash2.hs:14:1)
x :: w1 (bound at TidyClash2.hs:14:8)
barry :: w1 -> w2 -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:14:40: error:
• Found type wildcard ‘_’ standing for ‘w2
Where: ‘w2’ is a rigid type variable bound by
the inferred type of <expression> :: w2
• Found type wildcard ‘_’ standing for ‘w3
Where: ‘w3’ is a rigid type variable bound by
the inferred type of <expression> :: w3
at TidyClash2.hs:14:40
To use the inferred type, enable PartialTypeSignatures
• In an expression type signature: _
......@@ -55,6 +55,6 @@ TidyClash2.hs:14:40: error:
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
y :: w1 (bound at TidyClash2.hs:14:17)
x :: w (bound at TidyClash2.hs:14:8)
barry :: w -> w1 -> t (bound at TidyClash2.hs:14:1)
y :: w2 (bound at TidyClash2.hs:14:17)
x :: w1 (bound at TidyClash2.hs:14:8)
barry :: w1 -> w2 -> t (bound at TidyClash2.hs:14:1)
......@@ -10,9 +10,9 @@ T14265.hs:7:12: error:
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 ()
• Found type wildcard ‘_’ standing for ‘w1
Where: ‘w1’ is a rigid type variable bound by
the inferred type of foo :: StateT w1 w2 ()
at T14265.hs:11:1-15
To use the inferred type, enable PartialTypeSignatures
• In the first argument of ‘StateT’, namely ‘_’
......@@ -20,9 +20,9 @@ T14265.hs:10:15: error:
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 ()
• Found type wildcard ‘_’ standing for ‘w2 :: * -> *’
Where: ‘w2’ is a rigid type variable bound by
the inferred type of foo :: StateT w1 w2 ()
at T14265.hs:11:1-15
To use the inferred type, enable PartialTypeSignatures
• In the second argument of ‘StateT’, namely ‘_’
......
T16244.hs:12:18: error:
• Expected kind ‘k’, but ‘b’ has kind ‘k1
‘k1’ is a rigid type variable bound by
• Expected kind ‘k1’, but ‘b’ has kind ‘k2
‘k2’ is a rigid type variable bound by
the class declaration for ‘C’
at T16244.hs:12:26
‘k’ is a rigid type variable bound by
‘k1’ is a rigid type variable bound by
the class declaration for ‘C’
at T16244.hs:12:1-52
• In the second argument of ‘SameKind’, namely ‘b’
......
T16245.hs:12:36: error:
• Expected kind ‘k’, but ‘b’ has kind ‘k1
‘k1’ is a rigid type variable bound by
• Expected kind ‘k1’, but ‘b’ has kind ‘k2
‘k2’ is a rigid type variable bound by
the class declaration for ‘C’
at T16245.hs:12:45
‘k’ is a rigid type variable bound by
‘k1’ is a rigid type variable bound by
the class declaration for ‘C’
at T16245.hs:12:1-62
• In the second argument of ‘SameKind’, namely ‘b’
......
T16245a.hs:11:66: error:
• Expected kind ‘k’, but ‘b’ has kind ‘k1
‘k1’ is a rigid type variable bound by
• Expected kind ‘k1’, but ‘b’ has kind ‘k2
‘k2’ is a rigid type variable bound by
the newtype declaration for ‘T’
at T16245a.hs:11:12
‘k’ is a rigid type variable bound by
‘k1’ is a rigid type variable bound by
the newtype declaration for ‘T’
at T16245a.hs:11:1-67
• In the second argument of ‘SameKind’, namely ‘b’
......
T7438.hs:6:14: error:
• Could not deduce (p ~ p1)
• Could not deduce (p1 ~ p2)
from the context: b ~ a
bound by a pattern with constructor:
Nil :: forall {k} (a :: k). Thrist a a,
in an equation for ‘go’
at T7438.hs:6:4-6
‘p’ is a rigid type variable bound by
the inferred type of go :: Thrist a b -> p -> p1
at T7438.hs:6:1-16
‘p1’ is a rigid type variable bound by
the inferred type of go :: Thrist a b -> p -> p1
the inferred type of go :: Thrist a b -> p1 -> p2
at T7438.hs:6:1-16
‘p2’ is a rigid type variable bound by
the inferred type of go :: Thrist a b -> p1 -> p2
at T7438.hs:6:1-16
• In the expression: acc
In an equation for ‘go’: go Nil acc = acc
• Relevant bindings include
acc :: p (bound at T7438.hs:6:8)
go :: Thrist a b -> p -> p1 (bound at T7438.hs:6:1)
acc :: p1 (bound at T7438.hs:6:8)
go :: Thrist a b -> p1 -> p2 (bound at T7438.hs:6:1)
Suggested fix: Consider giving ‘go’ a type signature
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment