[commit: ghc] ghc-8.6: Fix #15527 by pretty-printing an RdrName prefixly (fb8b2cb)

git at git.haskell.org git at git.haskell.org
Tue Aug 21 22:56:58 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/fb8b2cb11023dd453b22ba49b7535b6ae8a8b506/ghc

>---------------------------------------------------------------

commit fb8b2cb11023dd453b22ba49b7535b6ae8a8b506
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Thu Aug 16 11:53:33 2018 +0200

    Fix #15527 by pretty-printing an RdrName prefixly
    
    Summary:
    When `(.) @Int` is used without enabling `TypeApplications`,
    the resulting error message will pretty-print the (symbolic)
    `RdrName` `(.)`. However, it does so without parenthesizing it, which
    causes the pretty-printed expression to appear as `. at Int`. Yuck.
    
    Since the expression in a type application will always be prefix,
    we can fix this issue by using `pprPrefixOcc` instead of plain ol'
    `ppr`.
    
    Test Plan: make test TEST=T15527
    
    Reviewers: bgamari, monoidal, simonpj
    
    Reviewed By: monoidal, simonpj
    
    Subscribers: rwbarton, carter
    
    GHC Trac Issues: #15527
    
    Differential Revision: https://phabricator.haskell.org/D5071
    
    (cherry picked from commit 5238f204482ac7f05f4e2d2e92576288cc00d42d)


>---------------------------------------------------------------

fb8b2cb11023dd453b22ba49b7535b6ae8a8b506
 compiler/hsSyn/HsExpr.hs                            | 2 +-
 docs/users_guide/8.6.1-notes.rst                    | 4 ++++
 testsuite/tests/typecheck/should_fail/T15527.hs     | 4 ++++
 testsuite/tests/typecheck/should_fail/T15527.stderr | 4 ++++
 testsuite/tests/typecheck/should_fail/all.T         | 1 +
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index a5c65fb..6ca37e0 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -1087,7 +1087,7 @@ ppr_expr (ArithSeq _ _ info) = brackets (ppr info)
 
 ppr_expr (EWildPat _)     = char '_'
 ppr_expr (ELazyPat _ e)   = char '~' <> ppr e
-ppr_expr (EAsPat _ v e)   = ppr v <> char '@' <> ppr e
+ppr_expr (EAsPat _ (L _ v) e) = pprPrefixOcc v <> char '@' <> ppr e
 ppr_expr (EViewPat _ p e) = ppr p <+> text "->" <+> ppr e
 
 ppr_expr (HsSCC _ st (StringLiteral stl lbl) expr)
diff --git a/docs/users_guide/8.6.1-notes.rst b/docs/users_guide/8.6.1-notes.rst
index 0cd1dd7..fccc0d1 100644
--- a/docs/users_guide/8.6.1-notes.rst
+++ b/docs/users_guide/8.6.1-notes.rst
@@ -162,6 +162,10 @@ Compiler
   <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst>`__
   in a future release.
 
+- The :ghc-flag:`-package-env ⟨file⟩|⟨name⟩` flag and ``GHC_ENVIRONMENT``
+  environment variable now accept the ``-`` value, which instructs GHC to ignore
+  any package environment files.
+
 Plugins
 ~~~~~~~
 
diff --git a/testsuite/tests/typecheck/should_fail/T15527.hs b/testsuite/tests/typecheck/should_fail/T15527.hs
new file mode 100644
index 0000000..b65c26c
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T15527.hs
@@ -0,0 +1,4 @@
+module T15527 where
+
+f :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)
+f =  (.) @Int
diff --git a/testsuite/tests/typecheck/should_fail/T15527.stderr b/testsuite/tests/typecheck/should_fail/T15527.stderr
new file mode 100644
index 0000000..dd03a0a
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T15527.stderr
@@ -0,0 +1,4 @@
+
+T15527.hs:4:6: error:
+    Pattern syntax in expression context: (.)@Int
+    Did you mean to enable TypeApplications?
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 6a00127..e2d6b71 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -474,3 +474,4 @@ test('T14884', normal, compile_fail, [''])
 test('T14904a', normal, compile_fail, [''])
 test('T14904b', normal, compile_fail, [''])
 test('T15067', normal, compile_fail, [''])
+test('T15527', normal, compile_fail, [''])



More information about the ghc-commits mailing list