summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-02-25 15:42:40 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-02-25 15:45:10 +0200
commit8f20844d3435094583db92a30550ca319d2be863 (patch)
tree91204b70edf6b49aaccf4bbef4a08124734d6f71
parent8f15ab98a7fe7484089b48c94328fa2980978890 (diff)
downloadhaskell-8f20844d3435094583db92a30550ca319d2be863.tar.gz
Correctly pretty print a wild card in infix position
-rw-r--r--compiler/hsSyn/HsExpr.hs1
-rw-r--r--testsuite/tests/printer/Makefile4
-rw-r--r--testsuite/tests/printer/T13050p.hs6
-rw-r--r--testsuite/tests/printer/all.T1
4 files changed, 12 insertions, 0 deletions
diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index 71c408984b..6ec0f0a65a 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -852,6 +852,7 @@ ppr_expr (OpApp e1 op _ e2)
should_print_infix (HsRecFld f) = Just (pprInfixOcc f)
should_print_infix (HsUnboundVar h@TrueExprHole{})
= Just (pprInfixOcc (unboundVarOcc h))
+ should_print_infix EWildPat = Just (text "`_`")
should_print_infix (HsWrap _ e) = should_print_infix e
should_print_infix _ = Nothing
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index bc2a4ed998..9f0eb23208 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -201,3 +201,7 @@ ppr048:
.PHONY: T13199
T13199:
$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T13199.hs
+
+.PHONY: T13050p
+T13050p:
+ $(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T13050p.hs
diff --git a/testsuite/tests/printer/T13050p.hs b/testsuite/tests/printer/T13050p.hs
new file mode 100644
index 0000000000..d40c476dcd
--- /dev/null
+++ b/testsuite/tests/printer/T13050p.hs
@@ -0,0 +1,6 @@
+module HolesInfix where
+
+f, g, q :: Int -> Int -> Int
+f x y = _ x y
+g x y = x `_` y
+q x y = x `_a` y
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 3106f936ba..e5fd00fdeb 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -47,3 +47,4 @@ test('Ppr046', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr04
test('Ppr047', expect_fail, run_command, ['$MAKE -s --no-print-directory ppr047'])
test('Ppr048', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr048'])
test('T13199', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T13199'])
+test('T13050p', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T13050p'])