summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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, [''])