Commit a08f463b authored by Alex D's avatar Alex D 🍄 Committed by Marge Bot
Browse files

Fix #15849 by checking whether there's a do block

parent 8b476d82
Pipeline #2156 passed with stages
in 432 minutes and 4 seconds
......@@ -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
......
module T15849 where
main = return ()
foo = return ()
T15849.hs:4:6: error:
parse error on input ‘=’
......@@ -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, [''])
......
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'
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'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment