[GHC] #10498: "if ... then \case -> else ..." causes a "missing else clause" error

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: | Owner: dramforever | Status: new Type: bug | Milestone: Priority: normal | Version: 7.10.1 Component: Compiler | Operating System: Unknown/Multiple (Parser) | Type of failure: Other Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- The following program: {{{#!hs {-# LANGUAGE LambdaCase #-} foo = if True then \case -> 1 -> 2 else id }}} Produces this message: {{{ problem.hs:4:5: parse error in if statement: missing required else clause }}} The problem in the code is that there's a -> after the \case. I don't know if a better error message can be generated, but this one is really unhelpful. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by dramforever): I ran into this in another more complex program yesterday. It took me 15 mins to find out the real cause of the error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Regression since 7.8 ("parse error on input ‘->’"), so I guess it is caused by Phab:D201. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * cc: MikeIzbicki (added) * milestone: => 7.10.3 Comment: @MikeIzbicki: as the author of Phab:D201, could you have a look? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by MikeIzbicki): I'm sorry, but I doubt I'll have time to look into this anytime soon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: newcomer 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 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: patch 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 Rev(s): Phab:D1309 -------------------------------------+------------------------------------- Changes (by thomie): * status: new => patch * differential: => Phab:D1309 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: patch 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 Rev(s): Phab:D1309 -------------------------------------+------------------------------------- Comment (by simonmar): Worth double-checking to see whether the set of shift/reduce conflicts in `Parser.y` needs updating. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10498: "if ... then \case -> else ..." causes a "missing else clause" error
-------------------------------------+-------------------------------------
Reporter: dramforever | Owner:
Type: bug | Status: patch
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 Rev(s): Phab:D1309
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: merge 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 Rev(s): Phab:D1309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10498: "if ... then \case -> else ..." causes a "missing else clause" error -------------------------------------+------------------------------------- Reporter: dramforever | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.3 Component: Compiler | Version: 7.10.1 (Parser) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10498#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC