summaryrefslogtreecommitdiff
path: root/compiler
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 /compiler
parentef8a08e0dd4e5b908b7fbce1b3101dc311c4d3e1 (diff)
downloadhaskell-b79e46d682d144c6a7a9ff6e7dca0d892b690654.tar.gz
Strip parentheses in expressions contexts in error messages
This makes error messages a tad less noisy.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Hs/Expr.hs4
-rw-r--r--compiler/typecheck/TcExpr.hs2
2 files changed, 5 insertions, 1 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