
#10707: -fth-dec-file outputs invalid case clauses -------------------------------------+------------------------------------- Reporter: Fabian | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #10701 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bollmann): Replying to [comment:4 Fabian]:
Replying to [comment:3 rwbarton]:
I'm not sure what you mean by "invalid case clauses", but it seems to me that the error is that {{{ case e of { ...alts... } foo }}} is not valid syntax for an application, it must be parenthesized like {{{ (case e of { ...alts... }) foo }}} A problem with the case expression itself in its context, not the case clauses.
I wasn't sure exactly what was wrong with the output
According to Fabian's specified AST (see the attached Test.hs), the problem rather seems to be missing parentheses around the lambda abstraction as well as missing semi-colons to separate the cases. That is, instead of pretty-printing {{{ instance Data.Aeson.Types.Class.ToJSON Language.Haskell.TH.Syntax.Name where Data.Aeson.Types.Class.toJSON x = \ k_a94l v_a94m -> case k_a94l of { GHC.Base.Just "" -> GHC.Err.undefined GHC.Base.Nothing -> GHC.Err.undefined } (GHC.Base.Just "test") "test2" }}} the code should be pretty-printed as: {{{ instance Data.Aeson.Types.Class.ToJSON Language.Haskell.TH.Syntax.Name where Data.Aeson.Types.Class.toJSON x = (\ k_a94l v_a94m -> case k_a94l of { GHC.Base.Just "" -> GHC.Err.undefined; -- note the ';' here GHC.Base.Nothing -> GHC.Err.undefined }) -- note the parentheses (GHC.Base.Just "test") "test2" }}} That should be easy to fix. I'll have a look. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10707#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler