diff options
| author | Rupert Horlick <ruperthorlick@gmail.com> | 2017-03-29 15:26:11 -0400 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-29 16:07:52 -0400 |
| commit | 5856c564dff79a5c2b6a92b1c6c350798b538da3 (patch) | |
| tree | a7c0fa6aaf938524bafd003f659e4e40990eea27 | |
| parent | b04ded8fca8ee8b0cd9c7c055bc5dc61ef2be1fe (diff) | |
| download | haskell-5856c564dff79a5c2b6a92b1c6c350798b538da3.tar.gz | |
Fixed error messages for RecursiveDo (#8501)
Changes in a few different places to catch several different
types of error related to RecursiveDo
Signed-off-by: Rupert Horlick <ruperthorlick@gmail.com>
Test Plan: Three test cases, with further tests in comments
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3271
| -rw-r--r-- | compiler/parser/Lexer.x | 10 | ||||
| -rw-r--r-- | compiler/parser/RdrHsSyn.hs | 7 | ||||
| -rw-r--r-- | compiler/rename/RnEnv.hs | 10 | ||||
| -rw-r--r-- | compiler/utils/StringBuffer.hs | 15 | ||||
| -rw-r--r-- | testsuite/tests/ghci/prog011/prog011.stderr | 2 | ||||
| -rw-r--r-- | testsuite/tests/ghci/scripts/ghci014.stdout | 982 | ||||
| -rw-r--r-- | testsuite/tests/mdo/should_fail/mdofail005.stderr | 4 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501a.hs | 27 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501a.stderr | 4 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501b.hs | 10 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501b.stderr | 4 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501c.hs | 15 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/T8501c.stderr | 6 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/all.T | 3 | ||||
| -rw-r--r-- | testsuite/tests/parser/should_fail/readFail040.stderr | 4 |
15 files changed, 111 insertions, 992 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index a6e0a7b54d..4c86688ea9 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -2405,14 +2405,18 @@ srcParseErr options buf len $$ ppWhen (not th_enabled && token == "$") -- #7396 (text "Perhaps you intended to use TemplateHaskell") $$ ppWhen (token == "<-") - (text "Perhaps this statement should be within a 'do' block?") + (if mdoInLast100 + then text "Perhaps you intended to use RecursiveDo" + else text "Perhaps this statement should be within a 'do' block?") $$ 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 + $$ 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 + pattern = decodePrevNChars 8 buf + last100 = decodePrevNChars 100 buf + mdoInLast100 = "mdo" `isInfixOf` last100 th_enabled = extopt LangExt.TemplateHaskell options ps_enabled = extopt LangExt.PatternSynonyms options diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index e06c7e36c0..5b1006ac79 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -805,8 +805,10 @@ checkLPat msg e@(L l _) = checkPat msg l e [] checkPat :: SDoc -> SrcSpan -> LHsExpr RdrName -> [LPat RdrName] -> P (LPat RdrName) -checkPat _ loc (L l (HsVar (L _ c))) args +checkPat _ loc (L l e@(HsVar (L _ c))) args | isRdrDataCon c = return (L loc (ConPatIn (L l c) (PrefixCon args))) + | not (null args) && patIsRec c = + patFail (text "Perhaps you intended to use RecursiveDo") l e checkPat msg loc e args -- OK to let this happen even if bang-patterns -- are not enabled, because there is no valid -- non-bang-pattern parse of (C ! e) @@ -913,6 +915,9 @@ patFail msg loc e = parseErrorSDoc loc err where err = text "Parse error in pattern:" <+> ppr e $$ msg +patIsRec :: RdrName -> Bool +patIsRec e = e == mkUnqual varName (fsLit "rec") + --------------------------------------------------------------------------- -- Check Equation Syntax diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index 509e26e1fc..7484061856 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -1856,7 +1856,8 @@ unknownNameSuggestions_ :: WhereLooking -> DynFlags -> RdrName -> SDoc unknownNameSuggestions_ where_look dflags global_env local_env imports tried_rdr_name = similarNameSuggestions where_look dflags global_env local_env tried_rdr_name $$ - importSuggestions where_look imports tried_rdr_name + importSuggestions where_look imports tried_rdr_name $$ + extensionSuggestions tried_rdr_name similarNameSuggestions :: WhereLooking -> DynFlags @@ -2087,6 +2088,13 @@ importSuggestions where_look imports rdr_name (helpful_imports_hiding, helpful_imports_non_hiding) = partition (imv_is_hiding . snd) helpful_imports +extensionSuggestions :: RdrName -> SDoc +extensionSuggestions rdrName + | rdrName == mkUnqual varName (fsLit "mdo") || + rdrName == mkUnqual varName (fsLit "rec") + = text "Perhaps you meant to use RecursiveDo" + | otherwise = Outputable.empty + {- ************************************************************************ * * diff --git a/compiler/utils/StringBuffer.hs b/compiler/utils/StringBuffer.hs index bac752ac28..ec5184a1c2 100644 --- a/compiler/utils/StringBuffer.hs +++ b/compiler/utils/StringBuffer.hs @@ -36,6 +36,7 @@ module StringBuffer -- * Conversion lexemeToString, lexemeToFastString, + decodePrevNChars, -- * Parsing integers parseUnsignedInteger, @@ -263,6 +264,20 @@ lexemeToFastString (StringBuffer buf _ cur) len = withForeignPtr buf $ \ptr -> return $! mkFastStringBytes (ptr `plusPtr` cur) len +-- | Return the previous @n@ characters (or fewer if we are less than @n@ +-- characters into the buffer. +decodePrevNChars :: Int -> StringBuffer -> String +decodePrevNChars n (StringBuffer buf _ cur) = + inlinePerformIO $ withForeignPtr buf $ \p0 -> + go p0 n "" (p0 `plusPtr` (cur - 1)) + where + go :: Ptr Word8 -> Int -> String -> Ptr Word8 -> IO String + go buf0 n acc p | n == 0 || buf0 >= p = return acc + go buf0 n acc p = do + p' <- utf8PrevChar p + let (c,_) = utf8DecodeChar p' + go buf0 (n - 1) (c:acc) p' + -- ----------------------------------------------------------------------------- -- Parsing integer strings in various bases parseUnsignedInteger :: StringBuffer -> Int -> Integer -> (Char->Int) -> Integer diff --git a/testsuite/tests/ghci/prog011/prog011.stderr b/testsuite/tests/ghci/prog011/prog011.stderr index 6ee1facfdc..68c310dcf5 100644 --- a/testsuite/tests/ghci/prog011/prog011.stderr +++ b/testsuite/tests/ghci/prog011/prog011.stderr @@ -1,2 +1,2 @@ -prog011.hx:14:22: Empty 'do' block +prog011.hx:14:22: error: Empty 'do' block diff --git a/testsuite/tests/ghci/scripts/ghci014.stdout b/testsuite/tests/ghci/scripts/ghci014.stdout deleted file mode 100644 index 324972da57..0000000000 --- a/testsuite/tests/ghci/scripts/ghci014.stdout +++ /dev/null @@ -1,982 +0,0 @@ - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) - test : * (0) diff --git a/testsuite/tests/mdo/should_fail/mdofail005.stderr b/testsuite/tests/mdo/should_fail/mdofail005.stderr index 594fea2a19..0ebead149f 100644 --- a/testsuite/tests/mdo/should_fail/mdofail005.stderr +++ b/testsuite/tests/mdo/should_fail/mdofail005.stderr @@ -1,4 +1,4 @@ -mdofail005.hs:11:14: +mdofail005.hs:11:14: error: parse error on input ‘<-’ - Perhaps this statement should be within a 'do' block? + Perhaps you intended to use RecursiveDo diff --git a/testsuite/tests/parser/should_fail/T8501a.hs b/testsuite/tests/parser/should_fail/T8501a.hs new file mode 100644 index 0000000000..e8b06415e4 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501a.hs @@ -0,0 +1,27 @@ +module Test where + +foo :: IO () +foo = do + rec str <- return "foo" + putStrLn str + +-- Should fail +-- foo' :: IO () +-- foo' = do +-- rec {str <- return "foo" ; +-- putStrLn str} +-- return () + +-- Should fail +-- foo'' :: IO () +-- foo'' = do +-- rec putStrLn "test" +-- str <- return "foo" +-- putStrLn str +-- return () + +-- Should compile +-- foo'''' :: IO () +-- foo'''' = do +-- rec <- return "foo" +-- putStrLn "test" diff --git a/testsuite/tests/parser/should_fail/T8501a.stderr b/testsuite/tests/parser/should_fail/T8501a.stderr new file mode 100644 index 0000000000..d85dfc29f9 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501a.stderr @@ -0,0 +1,4 @@ + +T8501a.hs:5:3: error: + Parse error in pattern: rec + Perhaps you intended to use RecursiveDo diff --git a/testsuite/tests/parser/should_fail/T8501b.hs b/testsuite/tests/parser/should_fail/T8501b.hs new file mode 100644 index 0000000000..3973ccb29e --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501b.hs @@ -0,0 +1,10 @@ +module Test where + +bar :: IO () +bar = mdo + str <- return "bar" + putStrLn str + +-- Should fail +-- bar' :: IO () +-- bar' = mdo {str <- return "bar" ; putStrLn str} diff --git a/testsuite/tests/parser/should_fail/T8501b.stderr b/testsuite/tests/parser/should_fail/T8501b.stderr new file mode 100644 index 0000000000..e9e4b5ec91 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501b.stderr @@ -0,0 +1,4 @@ + +T8501b.hs:5:9: error: + parse error on input ‘<-’ + Perhaps you intended to use RecursiveDo diff --git a/testsuite/tests/parser/should_fail/T8501c.hs b/testsuite/tests/parser/should_fail/T8501c.hs new file mode 100644 index 0000000000..8dea9565da --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501c.hs @@ -0,0 +1,15 @@ +module Test where + +baz :: IO () +baz = mdo + putStrLn "baz" + +-- Should fail +-- baz' :: IO () +-- baz' = mdo +-- putStrLn "baz" +-- str <- return "test" + +-- Should fail (and needs better error) +-- baz' :: IO () +-- baz' = mdo {putStrLn "baz"} diff --git a/testsuite/tests/parser/should_fail/T8501c.stderr b/testsuite/tests/parser/should_fail/T8501c.stderr new file mode 100644 index 0000000000..b12b53e8ad --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8501c.stderr @@ -0,0 +1,6 @@ + +T8501c.hs:4:7: error: + • Variable not in scope: + mdo :: (String -> IO ()) -> [Char] -> IO () + • Perhaps you meant ‘mod’ (imported from Prelude) + Perhaps you meant to use RecursiveDo diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index b897484c6e..883e0b2efa 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -98,3 +98,6 @@ test('T12429', normal, compile_fail, ['']) test('T12811', normal, compile_fail, ['']) test('T13260', normal, compile_fail, ['']) test('T13414', literate, compile_fail, ['']) +test('T8501a', normal, compile_fail, ['']) +test('T8501b', normal, compile_fail, ['']) +test('T8501c', normal, compile_fail, ['']) diff --git a/testsuite/tests/parser/should_fail/readFail040.stderr b/testsuite/tests/parser/should_fail/readFail040.stderr index 728090b9ec..663220da26 100644 --- a/testsuite/tests/parser/should_fail/readFail040.stderr +++ b/testsuite/tests/parser/should_fail/readFail040.stderr @@ -1,4 +1,4 @@ -readFail040.hs:7:11: +readFail040.hs:7:11: error: parse error on input ‘<-’ - Perhaps this statement should be within a 'do' block? + Perhaps you intended to use RecursiveDo |
