summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Bielecki <zyla@prati.pl>2017-01-02 17:03:00 -0500
committerBen Gamari <ben@smart-cactus.org>2017-01-02 17:44:50 -0500
commitb28ca38e6e1d75f3c10cc593cdd2ac80ec29690f (patch)
treed861809f4c3aea12c510341b5c64e3010b3d0e21
parentcc0abfa40b00b3b3ad4f4cf31b060026d677488a (diff)
downloadhaskell-b28ca38e6e1d75f3c10cc593cdd2ac80ec29690f.tar.gz
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
-rw-r--r--compiler/rename/RnExpr.hs10
-rw-r--r--testsuite/tests/rename/should_fail/T12879.hs4
-rw-r--r--testsuite/tests/rename/should_fail/T12879.stderr4
-rw-r--r--testsuite/tests/rename/should_fail/all.T1
4 files changed, 17 insertions, 2 deletions
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 811ecbafbe..17c9042f22 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/rename/should_fail/T12879.hs b/testsuite/tests/rename/should_fail/T12879.hs
new file mode 100644
index 0000000000..3f62207f15
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T12879.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE TypeApplications #-}
+module ShouldFail where
+
+f x = x@x
diff --git a/testsuite/tests/rename/should_fail/T12879.stderr b/testsuite/tests/rename/should_fail/T12879.stderr
new file mode 100644
index 0000000000..1b3559c255
--- /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@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 b8c1ac51e5..d42ca5675f 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, [''])