summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/parser/Lexer.x4
-rw-r--r--testsuite/tests/parser/should_fail/T12429.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T12429.stderr7
-rw-r--r--testsuite/tests/parser/should_fail/all.T1
4 files changed, 15 insertions, 0 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 3c5d98d054..6f91f44241 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -2394,8 +2394,12 @@ srcParseErr options buf len
$$ ppWhen (token == "=")
(text "Perhaps you need a 'let' in a 'do' block?"
$$ text "e.g. 'let x = 5' instead of 'x = 5'")
+ $$ ppWhen (not ps_enabled && pattern == "pattern") -- #12429
+ (text "Perhaps you intended to use PatternSynonyms")
where token = lexemeToString (offsetBytes (-len) buf) len
+ pattern = lexemeToString (offsetBytes (-len - 8) buf) 7
th_enabled = extopt LangExt.TemplateHaskell options
+ ps_enabled = extopt LangExt.PatternSynonyms options
-- Report a parse failure, giving the span of the previous token as
-- the location of the error. This is the entry point for errors
diff --git a/testsuite/tests/parser/should_fail/T12429.hs b/testsuite/tests/parser/should_fail/T12429.hs
new file mode 100644
index 0000000000..3e0496b458
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T12429.hs
@@ -0,0 +1,3 @@
+module X where
+ import Data.Text (pattern Y)
+ x = 3
diff --git a/testsuite/tests/parser/should_fail/T12429.stderr b/testsuite/tests/parser/should_fail/T12429.stderr
new file mode 100644
index 0000000000..fde11ec5eb
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T12429.stderr
@@ -0,0 +1,7 @@
+
+testsuite/tests/parser/should_fail/T12429.hs:2:29: error:
+ parse error on input ‘Y’
+ Perhaps you intended to use PatternSynonyms
+ |
+2 | import Data.Text (pattern Y)
+ | ^
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index ca23d3b5b6..e515e2fd6b 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -94,3 +94,4 @@ test('T10196Fail2', normal, compile_fail, [''])
test('T10498a', normal, compile_fail, [''])
test('T10498b', normal, compile_fail, [''])
test('T12051', normal, compile_fail, [''])
+test('T12429', normal, compile_fail, [''])