[commit: ghc] ghc-8.0: Improve accuracy of suggestion to use TypeApplications (0241540)

git at git.haskell.org git at git.haskell.org
Tue Aug 23 02:00:02 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/02415404ab26a5f12dffd9c98f2a923dbdde2329/ghc

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

commit 02415404ab26a5f12dffd9c98f2a923dbdde2329
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date:   Thu Feb 25 15:51:46 2016 +0100

    Improve accuracy of suggestion to use TypeApplications
    
    The suggestion only makes sense when we try
    to use an as pattern in an expression context.
    
    It is misleading in the case of a lazy pattern and
    view pattern.
    
    Reviewers: austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1948
    
    (cherry picked from commit e38c07bf5ceb8f50fa5110b70b3b83f0ce1358ba)


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

02415404ab26a5f12dffd9c98f2a923dbdde2329
 compiler/rename/RnExpr.hs                           | 13 +++++++------
 testsuite/tests/module/mod70.stderr                 |  4 +---
 testsuite/tests/rename/should_fail/rnfail016.stderr |  4 +---
 testsuite/tests/rename/should_fail/rnfail051.stderr |  1 -
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 5d97332..077d5bb 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -333,9 +333,10 @@ We return a (bogus) EWildPat in each case.
 -}
 
 rnExpr EWildPat        = return (hsHoleExpr, emptyFVs)   -- "_" is just a hole
-rnExpr e@(EAsPat {})   = patSynErr e
-rnExpr e@(EViewPat {}) = patSynErr e
-rnExpr e@(ELazyPat {}) = patSynErr e
+rnExpr e@(EAsPat {})   =
+  patSynErr e (text "Did you mean to enable TypeApplications?")
+rnExpr e@(EViewPat {}) = patSynErr e empty
+rnExpr e@(ELazyPat {}) = patSynErr e empty
 
 {-
 ************************************************************************
@@ -1967,10 +1968,10 @@ sectionErr expr
   = hang (text "A section must be enclosed in parentheses")
        2 (text "thus:" <+> (parens (ppr expr)))
 
-patSynErr :: HsExpr RdrName -> RnM (HsExpr Name, FreeVars)
-patSynErr e = do { addErr (sep [text "Pattern syntax in expression context:",
+patSynErr :: HsExpr RdrName -> SDoc -> RnM (HsExpr Name, FreeVars)
+patSynErr e explanation = do { addErr (sep [text "Pattern syntax in expression context:",
                                 nest 4 (ppr e)] $$
-                           text "Did you mean to enable TypeApplications?")
+                                  explanation)
                  ; return (EWildPat, emptyFVs) }
 
 badIpBinds :: Outputable a => SDoc -> a -> SDoc
diff --git a/testsuite/tests/module/mod70.stderr b/testsuite/tests/module/mod70.stderr
index f0e3042..616ef12 100644
--- a/testsuite/tests/module/mod70.stderr
+++ b/testsuite/tests/module/mod70.stderr
@@ -1,4 +1,2 @@
 
-mod70.hs:3:8: error:
-    Pattern syntax in expression context: ~1
-    Did you mean to enable TypeApplications?
+mod70.hs:3:8: error: Pattern syntax in expression context: ~1
diff --git a/testsuite/tests/rename/should_fail/rnfail016.stderr b/testsuite/tests/rename/should_fail/rnfail016.stderr
index 2193ffb..4013255 100644
--- a/testsuite/tests/rename/should_fail/rnfail016.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail016.stderr
@@ -3,6 +3,4 @@ rnfail016.hs:6:7: error:
     Pattern syntax in expression context: x at x
     Did you mean to enable TypeApplications?
 
-rnfail016.hs:7:7: error:
-    Pattern syntax in expression context: ~x
-    Did you mean to enable TypeApplications?
+rnfail016.hs:7:7: error: Pattern syntax in expression context: ~x
diff --git a/testsuite/tests/rename/should_fail/rnfail051.stderr b/testsuite/tests/rename/should_fail/rnfail051.stderr
index a06ddc5..9c45a61 100644
--- a/testsuite/tests/rename/should_fail/rnfail051.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail051.stderr
@@ -1,4 +1,3 @@
 
 rnfail051.hs:7:17: error:
     Pattern syntax in expression context: _ -> putStrLn "_"
-    Did you mean to enable TypeApplications?



More information about the ghc-commits mailing list