summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2019-11-15 10:01:07 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-19 20:39:20 -0500
commitb79e46d682d144c6a7a9ff6e7dca0d892b690654 (patch)
tree58b06bf198b38cdebc622f43532177fc07792f72
parentef8a08e0dd4e5b908b7fbce1b3101dc311c4d3e1 (diff)
downloadhaskell-b79e46d682d144c6a7a9ff6e7dca0d892b690654.tar.gz
Strip parentheses in expressions contexts in error messages
This makes error messages a tad less noisy.
-rw-r--r--compiler/GHC/Hs/Expr.hs4
-rw-r--r--compiler/typecheck/TcExpr.hs2
-rw-r--r--testsuite/tests/dependent/should_fail/T14066e.stderr2
-rw-r--r--testsuite/tests/deriving/should_fail/drvfail011.stderr2
-rw-r--r--testsuite/tests/indexed-types/should_fail/Overlap11.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr2
-rw-r--r--testsuite/tests/polykinds/KindVType.stderr2
-rw-r--r--testsuite/tests/th/T10279.stderr2
-rw-r--r--testsuite/tests/th/T17380.stderr2
-rw-r--r--testsuite/tests/th/TH_1tuple.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T10619.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/T6069.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail009.stderr10
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail032.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail104.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail208.stderr2
16 files changed, 31 insertions, 27 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index 72b758ee5e..52d0448cc6 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -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
diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index c7921070f6..712668f372 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -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
diff --git a/testsuite/tests/dependent/should_fail/T14066e.stderr b/testsuite/tests/dependent/should_fail/T14066e.stderr
index a6bf647bee..7216bc7b19 100644
--- a/testsuite/tests/dependent/should_fail/T14066e.stderr
+++ b/testsuite/tests/dependent/should_fail/T14066e.stderr
@@ -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)
diff --git a/testsuite/tests/deriving/should_fail/drvfail011.stderr b/testsuite/tests/deriving/should_fail/drvfail011.stderr
index e29f4e799b..d439bd03eb 100644
--- a/testsuite/tests/deriving/should_fail/drvfail011.stderr
+++ b/testsuite/tests/deriving/should_fail/drvfail011.stderr
@@ -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)’:
diff --git a/testsuite/tests/indexed-types/should_fail/Overlap11.stderr b/testsuite/tests/indexed-types/should_fail/Overlap11.stderr
index 36af24fbd1..f07c35b1b8 100644
--- a/testsuite/tests/indexed-types/should_fail/Overlap11.stderr
+++ b/testsuite/tests/indexed-types/should_fail/Overlap11.stderr
@@ -1,8 +1,8 @@
-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)
diff --git a/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr b/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
index a6dbd5a143..ea7e3d5214 100644
--- a/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
@@ -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)
diff --git a/testsuite/tests/polykinds/KindVType.stderr b/testsuite/tests/polykinds/KindVType.stderr
index 27e2e588a5..feb1417675 100644
--- a/testsuite/tests/polykinds/KindVType.stderr
+++ b/testsuite/tests/polykinds/KindVType.stderr
@@ -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)
diff --git a/testsuite/tests/th/T10279.stderr b/testsuite/tests/th/T10279.stderr
index 0d23a80877..d5f7052d05 100644
--- a/testsuite/tests/th/T10279.stderr
+++ b/testsuite/tests/th/T10279.stderr
@@ -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)
diff --git a/testsuite/tests/th/T17380.stderr b/testsuite/tests/th/T17380.stderr
index 7e1977b6e4..a2501a4cb4 100644
--- a/testsuite/tests/th/T17380.stderr
+++ b/testsuite/tests/th/T17380.stderr
@@ -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:
diff --git a/testsuite/tests/th/TH_1tuple.stderr b/testsuite/tests/th/TH_1tuple.stderr
index bc7f25ad81..3acb218b6e 100644
--- a/testsuite/tests/th/TH_1tuple.stderr
+++ b/testsuite/tests/th/TH_1tuple.stderr
@@ -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)
diff --git a/testsuite/tests/typecheck/should_fail/T10619.stderr b/testsuite/tests/typecheck/should_fail/T10619.stderr
index fde2daf8c6..9d34750675 100644
--- a/testsuite/tests/typecheck/should_fail/T10619.stderr
+++ b/testsuite/tests/typecheck/should_fail/T10619.stderr
@@ -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
diff --git a/testsuite/tests/typecheck/should_fail/T6069.stderr b/testsuite/tests/typecheck/should_fail/T6069.stderr
index e1c2e5653f..3ee2b2d5e4 100644
--- a/testsuite/tests/typecheck/should_fail/T6069.stderr
+++ b/testsuite/tests/typecheck/should_fail/T6069.stderr
@@ -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:
diff --git a/testsuite/tests/typecheck/should_fail/tcfail009.stderr b/testsuite/tests/typecheck/should_fail/tcfail009.stderr
index 2597a00c4b..7e4d29ae48 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail009.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail009.stderr
@@ -1,6 +1,6 @@
-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)]
diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.stderr b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
index 14be02dc45..a09941d284 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail032.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
@@ -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)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail104.stderr b/testsuite/tests/typecheck/should_fail/tcfail104.stderr
index 44d8e4888c..6516dcbd3a 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail104.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail104.stderr
@@ -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
diff --git a/testsuite/tests/typecheck/should_fail/tcfail208.stderr b/testsuite/tests/typecheck/should_fail/tcfail208.stderr
index d8b48cf2eb..cd8e6379e9 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail208.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail208.stderr
@@ -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)