Opened 5 months ago

#8501 new feature request

Improve error message when using rec/mdo keyword without RecursiveDo extention.

Reported by: shelarcy Owned by:
Priority: normal Milestone:
Component: Compiler (Parser) Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets: #3968

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.

Attachments (3)

NoRecursiveDo1.hs (83 bytes) - added by shelarcy 5 months ago.
NoRecursiveDo2.hs (81 bytes) - added by shelarcy 5 months ago.
NoRecursiveDo3.hs (59 bytes) - added by shelarcy 5 months ago.

Download all attachments as: .zip

Change History (3)

Changed 5 months ago by shelarcy

Changed 5 months ago by shelarcy

Changed 5 months ago by shelarcy

Note: See TracTickets for help on using tickets.