summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authornineonine <mail4chemik@gmail.com>2019-02-09 00:20:19 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-12 19:48:38 -0500
commita08f463bcc9727d91cec4c6e952ad0f5bbc3fbf9 (patch)
treed4b87146166e5fdb41068fd1c57ac307de7e6758 /compiler
parent8b476d822e97cfe4cebe6e74924d9a79148d608c (diff)
downloadhaskell-a08f463bcc9727d91cec4c6e952ad0f5bbc3fbf9.tar.gz
Fix #15849 by checking whether there's a do block
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser/Lexer.x3
1 files changed, 2 insertions, 1 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