[commit: ghc] master: Don't suggest enabling TypeApplications when it's already enabled (b28ca38)

git at git.haskell.org git at git.haskell.org
Mon Jan 2 22:45:14 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b28ca38e6e1d75f3c10cc593cdd2ac80ec29690f/ghc

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

commit b28ca38e6e1d75f3c10cc593cdd2ac80ec29690f
Author: Maciej Bielecki <zyla at prati.pl>
Date:   Mon Jan 2 17:03:00 2017 -0500

    Don't suggest enabling TypeApplications when it's already enabled
    
    Previously when encountering EAsPat in an expression context,
    TypeApplications was suggested even when already enabled. This patch
    replaces the suggestion with more appropriate message.
    
    Test Plan: validate
    
    Reviewers: austin, bgamari, mpickering, goldfire, simonpj
    
    Reviewed By: mpickering, goldfire, simonpj
    
    Subscribers: simonpj, goldfire, mpickering, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2877
    
    GHC Trac Issues: #12879


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

b28ca38e6e1d75f3c10cc593cdd2ac80ec29690f
 compiler/rename/RnExpr.hs                                      | 10 ++++++++--
 .../should_fail/T12529.hs => rename/should_fail/T12879.hs}     |  5 ++---
 testsuite/tests/rename/should_fail/T12879.stderr               |  4 ++++
 testsuite/tests/rename/should_fail/all.T                       |  1 +
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 811ecba..17c9042 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -336,8 +336,14 @@ We return a (bogus) EWildPat in each case.
 -}
 
 rnExpr EWildPat        = return (hsHoleExpr, emptyFVs)   -- "_" is just a hole
-rnExpr e@(EAsPat {})   =
-  patSynErr e (text "Did you mean to enable TypeApplications?")
+rnExpr e@(EAsPat {})
+  = do { opt_TypeApplications <- xoptM LangExt.TypeApplications
+       ; let msg | opt_TypeApplications
+                    = "Type application syntax requires a space before '@'"
+                 | otherwise
+                    = "Did you mean to enable TypeApplications?"
+       ; patSynErr e (text msg)
+       }
 rnExpr e@(EViewPat {}) = patSynErr e empty
 rnExpr e@(ELazyPat {}) = patSynErr e empty
 
diff --git a/testsuite/tests/typecheck/should_fail/T12529.hs b/testsuite/tests/rename/should_fail/T12879.hs
similarity index 50%
copy from testsuite/tests/typecheck/should_fail/T12529.hs
copy to testsuite/tests/rename/should_fail/T12879.hs
index ac4e31d..3f62207 100644
--- a/testsuite/tests/typecheck/should_fail/T12529.hs
+++ b/testsuite/tests/rename/should_fail/T12879.hs
@@ -1,5 +1,4 @@
 {-# LANGUAGE TypeApplications #-}
+module ShouldFail where
 
-module T12529 where
-
-f = p @ Int
+f x = x at x
diff --git a/testsuite/tests/rename/should_fail/T12879.stderr b/testsuite/tests/rename/should_fail/T12879.stderr
new file mode 100644
index 0000000..1b3559c
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T12879.stderr
@@ -0,0 +1,4 @@
+
+T12879.hs:4:7: error:
+    Pattern syntax in expression context: x at x
+    Type application syntax requires a space before '@'
diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T
index b8c1ac5..d42ca56 100644
--- a/testsuite/tests/rename/should_fail/all.T
+++ b/testsuite/tests/rename/should_fail/all.T
@@ -142,3 +142,4 @@ test('T11663', normal, compile_fail, [''])
 test('T12229', normal, compile, [''])
 test('T12681', normal, multimod_compile_fail, ['T12681','-v0'])
 test('T12686', normal, compile_fail, [''])
+test('T12879', normal, compile_fail, [''])



More information about the ghc-commits mailing list