Correctly pretty print a wild card in infix position
authorAlan Zimmerman <alan.zimm@gmail.com>
Sat, 25 Feb 2017 13:42:40 +0000 (15:42 +0200)
committerAlan Zimmerman <alan.zimm@gmail.com>
Sat, 25 Feb 2017 13:45:10 +0000 (15:45 +0200)
compiler/hsSyn/HsExpr.hs
testsuite/tests/printer/Makefile
testsuite/tests/printer/T13050p.hs [new file with mode: 0644]
testsuite/tests/printer/all.T

index 71c4089..6ec0f0a 100644 (file)
@@ -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
 
index bc2a4ed..9f0eb23 100644 (file)
@@ -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 (file)
index 0000000..d40c476
--- /dev/null
@@ -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
index 3106f93..e5fd00f 100644 (file)
@@ -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'])