summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/parser/Lexer.x3
-rw-r--r--testsuite/tests/parser/should_fail/T15849.hs4
-rw-r--r--testsuite/tests/parser/should_fail/T15849.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/all.T1
-rw-r--r--testsuite/tests/parser/should_fail/readFail011.stderr2
-rw-r--r--testsuite/tests/parser/should_fail/readFail034.stderr2
6 files changed, 10 insertions, 5 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 1e27158b80..929a6a6cbb 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -2585,7 +2585,7 @@ srcParseErr options buf len
(if mdoInLast100
then text "Perhaps you intended to use RecursiveDo"
else text "Perhaps this statement should be within a 'do' block?")
- $$ ppWhen (token == "=")
+ $$ ppWhen (token == "=" && doInLast100) -- #15849
(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
@@ -2593,6 +2593,7 @@ srcParseErr options buf len
where token = lexemeToString (offsetBytes (-len) buf) len
pattern = decodePrevNChars 8 buf
last100 = decodePrevNChars 100 buf
+ doInLast100 = "do" `isInfixOf` last100
mdoInLast100 = "mdo" `isInfixOf` last100
th_enabled = ThBit `xtest` pExtsBitmap options
ps_enabled = PatternSynonymsBit `xtest` pExtsBitmap options
diff --git a/testsuite/tests/parser/should_fail/T15849.hs b/testsuite/tests/parser/should_fail/T15849.hs
new file mode 100644
index 0000000000..eea8e4f9c1
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T15849.hs
@@ -0,0 +1,4 @@
+module T15849 where
+
+main = return ()
+ foo = return ()
diff --git a/testsuite/tests/parser/should_fail/T15849.stderr b/testsuite/tests/parser/should_fail/T15849.stderr
new file mode 100644
index 0000000000..e974dbde02
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T15849.stderr
@@ -0,0 +1,3 @@
+
+T15849.hs:4:6: error:
+ parse error on input ‘=’
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index ad23574358..7976c17a14 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -133,6 +133,7 @@ test('typeops_C', normal, compile_fail, [''])
test('typeops_D', normal, compile_fail, [''])
test('T15053', normal, compile_fail, [''])
test('T15233', normal, compile_fail, [''])
+test('T15849', normal, compile_fail, [''])
test('typeopsDataCon_A', normal, compile_fail, [''])
test('typeopsDataCon_B', normal, compile_fail, [''])
test('strictnessDataCon_A', normal, compile_fail, [''])
diff --git a/testsuite/tests/parser/should_fail/readFail011.stderr b/testsuite/tests/parser/should_fail/readFail011.stderr
index 25accd2a19..08388e5d21 100644
--- a/testsuite/tests/parser/should_fail/readFail011.stderr
+++ b/testsuite/tests/parser/should_fail/readFail011.stderr
@@ -1,5 +1,3 @@
readFail011.hs:7:10: error:
parse error on input ‘=’
- Perhaps you need a 'let' in a 'do' block?
- e.g. 'let x = 5' instead of 'x = 5'
diff --git a/testsuite/tests/parser/should_fail/readFail034.stderr b/testsuite/tests/parser/should_fail/readFail034.stderr
index 75156c9ae4..ad2fb000af 100644
--- a/testsuite/tests/parser/should_fail/readFail034.stderr
+++ b/testsuite/tests/parser/should_fail/readFail034.stderr
@@ -1,5 +1,3 @@
readFail034.hs:4:6: error:
parse error on input ‘=’
- Perhaps you need a 'let' in a 'do' block?
- e.g. 'let x = 5' instead of 'x = 5'