Commit b79e46d6 authored by Vladislav Zavialov's avatar Vladislav Zavialov Committed by Marge Bot

Strip parentheses in expressions contexts in error messages

This makes error messages a tad less noisy.
parent ef8a08e0
Pipeline #12997 failed with stages
in 532 minutes and 42 seconds
......@@ -1154,6 +1154,10 @@ parenthesizeHsExpr p le@(L loc e)
| hsExprNeedsParens p e = L loc (HsPar noExtField le)
| otherwise = le
stripParensHsExpr :: LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
stripParensHsExpr (L _ (HsPar _ e)) = stripParensHsExpr e
stripParensHsExpr e = e
isAtomicHsExpr :: HsExpr id -> Bool
-- True of a single token
isAtomicHsExpr (HsVar {}) = True
......
......@@ -2485,7 +2485,7 @@ addExprErrCtxt expr = addErrCtxt (exprCtxt expr)
exprCtxt :: LHsExpr GhcRn -> SDoc
exprCtxt expr
= hang (text "In the expression:") 2 (ppr expr)
= hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr))
fieldCtxt :: FieldLabelString -> SDoc
fieldCtxt field_name
......
......@@ -12,7 +12,7 @@ T14066e.hs:13:59: error:
Expected kind ‘c’, but ‘b'’ has kind ‘k1’
• In the first argument of ‘Proxy’, namely ‘(b' :: c')’
In an expression type signature: Proxy (b' :: c')
In the expression: (p1 :: Proxy (b' :: c'))
In the expression: p1 :: Proxy (b' :: c')
• Relevant bindings include
p2 :: Proxy c (bound at T14066e.hs:13:27)
p1 :: Proxy b (bound at T14066e.hs:13:10)
......
......@@ -2,7 +2,7 @@
drvfail011.hs:8:1: error:
• No instance for (Eq a) arising from a use of ‘==’
Possible fix: add (Eq a) to the context of the instance declaration
• In the expression: ((a1 == b1))
• In the expression: a1 == b1
In an equation for ‘==’: (==) (T1 a1) (T1 b1) = ((a1 == b1))
When typechecking the code for ‘==’
in a derived instance for ‘Eq (T a)’:
......
Overlap11.hs:10:8:
Couldn't match expected type ‘F a Int’ with actual type ‘Int’
In the expression: (5 :: Int)
In an equation for ‘g’: g x = (5 :: Int)
Relevant bindings include
x :: a (bound at Overlap11.hs:10:3)
g :: a -> F a Int (bound at Overlap11.hs:10:1)
Overlap11.hs:10:8: error:
Couldn't match expected type ‘F a Int’ with actual type ‘Int’
• In the expression: 5 :: Int
In an equation for ‘g’: g x = (5 :: Int)
Relevant bindings include
x :: a (bound at Overlap11.hs:10:3)
g :: a -> F a Int (bound at Overlap11.hs:10:1)
......@@ -6,7 +6,7 @@ ExprSigLocal.hs:9:35: warning: [-Wpartial-type-signatures (in -Wdefault)]
at ExprSigLocal.hs:9:20-35
• In the type ‘a -> _’
In an expression type signature: forall a. a -> _
In the expression: ((\ x -> x) :: forall a. a -> _)
In the expression: (\ x -> x) :: forall a. a -> _
• Relevant bindings include
y :: b -> b (bound at ExprSigLocal.hs:9:1)
......
......@@ -3,5 +3,5 @@ KindVType.hs:8:8: error:
• Couldn't match type ‘Int’ with ‘Maybe’
Expected type: Proxy Maybe
Actual type: Proxy Int
• In the expression: (Proxy :: Proxy Int)
• In the expression: Proxy :: Proxy Int
In an equation for ‘foo’: foo = (Proxy :: Proxy Int)
......@@ -4,5 +4,5 @@ T10279.hs:10:10: error:
no unit id matching ‘rts-1.0’ was found
(This unit ID looks like the source package ID;
the real unit ID is ‘rts’)
• In the expression: (rts-1.0:A.Foo)
• In the expression: rts-1.0:A.Foo
In an equation for ‘blah’: blah = (rts-1.0:A.Foo)
......@@ -8,7 +8,7 @@ T17380.hs:9:7: error:
T17380.hs:12:9: error:
• Couldn't match expected type ‘Maybe String’
with actual type ‘Unit (Maybe [Char])’
• In the expression: (Unit Just "wat")
• In the expression: Unit Just "wat"
In an equation for ‘bar’: bar = (Unit Just "wat")
T17380.hs:15:6: error:
......
......@@ -3,5 +3,5 @@ TH_1tuple.hs:11:7: error:
• Expecting one more argument to ‘Unit’
Expected a type, but ‘Unit’ has kind ‘* -> *’
• In an expression type signature: Unit
In the expression: (1 :: Unit)
In the expression: 1 :: Unit
In an equation for ‘y’: y = (1 :: Unit)
......@@ -4,7 +4,7 @@ T10619.hs:9:15: error:
Expected type: (b -> b) -> b -> b
Actual type: (forall a. a -> a) -> b -> b
• In the expression:
((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b)
(\ x -> x) :: (forall a. a -> a) -> forall b. b -> b
In the expression:
if True then
((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b)
......@@ -24,7 +24,7 @@ T10619.hs:14:15: error:
Expected type: (b -> b) -> b -> b
Actual type: (forall a. a -> a) -> b -> b
• In the expression:
((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b)
(\ x -> x) :: (forall a. a -> a) -> forall b. b -> b
In the expression:
if True then
\ y -> y
......
......@@ -12,7 +12,7 @@ T6069.hs:14:15: error:
Expected type: ST s1 Int -> a1
Actual type: (forall s. ST s a1) -> a1
• In the second argument of ‘(.)’, namely ‘runST’
In the expression: (print . runST)
In the expression: print . runST
In the expression: (print . runST) $ fourty_two
T6069.hs:15:16: error:
......
tcfail009.hs:3:17:
Couldn't match expected type ‘Int’ with actual type ‘Integer’
In the expression: (2 :: Integer)
In the expression: [(1 :: Int) .. (2 :: Integer)]
In an equation for ‘p’: p = [(1 :: Int) .. (2 :: Integer)]
tcfail009.hs:3:17: error:
Couldn't match expected type ‘Int’ with actual type ‘Integer’
• In the expression: 2 :: Integer
In the expression: [(1 :: Int) .. (2 :: Integer)]
In an equation for ‘p’: p = [(1 :: Int) .. (2 :: Integer)]
......@@ -6,7 +6,7 @@ tcfail032.hs:14:8: error:
an expression type signature:
forall a1. Eq a1 => a1 -> Int
at tcfail032.hs:14:13-30
• In the expression: (x :: (Eq a) => a -> Int)
• In the expression: x :: (Eq a) => a -> Int
In an equation for ‘f’: f x = (x :: (Eq a) => a -> Int)
• Relevant bindings include
x :: p (bound at tcfail032.hs:14:3)
......
......@@ -3,7 +3,7 @@ tcfail104.hs:14:12: error:
• Couldn't match type ‘forall a. a -> a’ with ‘Char -> Char’
Expected type: (Char -> Char) -> Char -> Char
Actual type: (forall a. a -> a) -> Char -> Char
• In the expression: (\ (x :: forall a. a -> a) -> x)
• In the expression: \ (x :: forall a. a -> a) -> x
In the expression:
if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)
In the expression:
......@@ -15,4 +15,4 @@ tcfail104.hs:22:15: error:
• When checking that the pattern signature: forall a. a -> a
fits the type of its context: Char -> Char
In the pattern: x :: forall a. a -> a
In the expression: (\ (x :: forall a. a -> a) -> x)
In the expression: \ (x :: forall a. a -> a) -> x
......@@ -5,5 +5,5 @@ tcfail208.hs:4:10: error:
bound by the type signature for:
f :: forall (m :: * -> *) a. (Monad m, Eq a) => a -> m a -> Bool
at tcfail208.hs:3:1-40
• In the expression: (return x == y)
• In the expression: return x == y
In an equation for ‘f’: f x y = (return x == y)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment