[GHC] #8501: Improve error message when using rec/mdo keyword without RecursiveDo extention.

GHC ghc-devs at haskell.org
Tue Nov 18 18:20:28 UTC 2014


#8501: Improve error message when using rec/mdo keyword without RecursiveDo
extention.
-------------------------------------+-------------------------------------
              Reporter:  shelarcy    |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.6.3
             Component:  Compiler    |         Keywords:
  (Parser)                           |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Unknown
      Operating System:              |       Blocked By:
  Unknown/Multiple                   |  Related Tickets:  #3968
       Type of failure:              |
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Description changed by thomie:

Old description:

> GHC shows unhelpful error message when using rec keyword and/or mdo
> keyword without RecursiveDo extention.
>
> {{{
> module NoRecursiveDo where
>
> foo = do
>     rec str <- return "foo"
>     putStrLn str
> }}}
>
> {{{
> $ ghc -c NoRecursiveDo.hs
>
> NoRecursiveDo1.hs:4:5: Parse error in pattern: rec
>
> }}}
>
> {{{
> module NoRecursiveDo2 where
>
> bar = mdo
>     str <- return "bar"
>     putStrLn str
> }}}
>
> {{{
> $ ghc -c NoRecursiveDo2.hs
>
> NoRecursiveDo2.hs:4:9: parse error on input `<-'
>
> }}}
>
> {{{
> module NoRecursiveDo3 where
>
> baz = mdo
>     putStrLn "baz"
> }}}
>
> {{{
> $ ghc -c NoRecursiveDo3.hs
>
> NoRecursiveDo3.hs:3:7:
>     Not in scope: `mdo'
>     Perhaps you meant `mod' (imported from Prelude)
>
> }}}
>
> I think that GHC should suggest to use RecursiveDo extention when using
> mdo/rec keyword.

New description:

 GHC shows unhelpful error message when using rec keyword and/or mdo
 keyword without RecursiveDo extention.

 {{{
 module NoRecursiveDo where

 foo = do
     rec str <- return "foo"
     putStrLn str
 }}}

 {{{
 $ ghc -c NoRecursiveDo.hs

 NoRecursiveDo1.hs:4:5:
     Parse error in pattern: rec
     Possibly caused by a missing 'do'?
 }}}

 {{{
 module NoRecursiveDo2 where

 bar = mdo
     str <- return "bar"
     putStrLn str
 }}}

 {{{
 $ ghc -c NoRecursiveDo2.hs

 NoRecursiveDo2.hs:4:9: parse error on input `<-'

 }}}

 {{{
 module NoRecursiveDo3 where

 baz = mdo
     putStrLn "baz"
 }}}

 {{{
 $ ghc -c NoRecursiveDo3.hs

 NoRecursiveDo3.hs:3:7:
     Not in scope: `mdo'
     Perhaps you meant `mod' (imported from Prelude)

 }}}

 I think that GHC should suggest to use RecursiveDo extention when using
 mdo/rec keyword.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8501#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list