
#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: Compiler | Version: 7.10.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * keywords: newcomer => Comment: I'm inclined to just the delete the parser changes from Phab:D201. They were supposed to make error messages better, but instead they make them worse. Here's an example from the testsuite (parser/should_fail/readFail020): {{{ f = let x = 42 } in x -- before: parse error on input ‘}’ -- after: parse error in let binding: missing required 'in' }}} Here's another: {{{ f = if module then True else False -- before: parse error on input ‘module’ -- after: parse error in if statement: naked if statement }}} For that last one, the parser code looks like this: {{{ | 'if' error {% hintIf (getLoc $1) "naked if statement" } | 'if' exp optSemi error {% ... something ... } | 'if' exp optSemi 'then' error {% ... something ... } | 'if' exp optSemi 'then' exp optSemi error {% ... something ... } | 'if' exp optSemi 'then' exp optSemi 'else' error {% ... something ... } }}} What this means is that a lexical error in the condition of an if- expression, that we don't handle gracefully in the parser, will be reported as "naked if statement". The example from the description has the same cause. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler