[GHC] #10945: Typed Template Haskell splices broken in HEAD (7.11)

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template | Version: 7.11 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | -------------------------------------+------------------------------------- In the latest HEAD (e2b579e8d77357e8b36f57d15daead101586ac8e) when I say: {{{#!hs $$(return [ SigD (mkName "m") (ForallT [PlainTV (mkName "a")] [] (AppT (AppT ArrowT (VarT (mkName "a"))) (VarT (mkName "a")))) , FunD (mkName "m") [Clause [VarP (mkName "x")] (NormalB (VarE (mkName "x"))) []] ]) }}} I get: {{{ ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.11.20151007 for x86_64-unknown-linux): runRnSplice $$(return [SigD (mkName "m") (ForallT [PlainTV (mkName "a")] [] (AppT (AppT ArrowT (VarT (mkName "a"))) (VarT (mkName "a")))), FunD (mkName "m") [Clause [VarP (mkName "x")] (NormalB (VarE (mkName "x"))) []]]) }}} This code compiles correctly in GHC 7.10.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: simonpj (added) Comment: The sequence of calls that leads to this panic goes like this: `TcRnDriver.tc_rn_src_decls` -> `RnSplice.rnTopSpliceDecls` -> `RnSplice.runRnSplice` and in `runRnSplice` we hit `HsTypedSplice` alternative in the case that scrutinizes `splice'`. Looking at git blame I conjecture that this bug was introduced in f46360ed7139ff25741b381647b0a0b6d1000d84 (but would need to bisect to verify), which was a fix for #10047. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11)
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Jan Stolarek

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by jstolarek): * testcase: => th/T10945 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by goldfire): Obviously we shouldn't panic, but the code above looks utterly bogus, for two reasons: 1. According to my understanding, typed splices only work for expressions -- no other contexts allowed. 2. The contents of a typed splice (of type `a`) must be `Q (TExp a)`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11)
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: th/T10945
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Jan Stolarek

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by jstolarek): * owner: => jstolarek -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jstolarek): I initially thought that this bogus code - ie. top-level typed TH splice - should be rejected as a parse error. I spent some time trying to change the parser to reject the code but I couldn't find a good way of doing that. Then I realized that this code should parse: with TH enabled all top-level expressions should really be accepted, including a typed TH splice. After some more thought I believe that the right way of doing this would be to run the typed TH splice and then report a type error in the same way we report a type error here: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module T10945s where import Language.Haskell.TH True }}} {{{ T10945.hs:8:1: Couldn't match type ‘Bool’ with ‘Q [Dec]’ Expected type: DecsQ Actual type: Bool In the expression: True }}} Before investing more time into this I'd like to hear thoughts from other devs. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jstolarek): Oh, I have a nearly-one-line fix. Will post patch later for review. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1344 Wiki Page: | -------------------------------------+------------------------------------- Changes (by jstolarek): * differential: => Phab:D1344 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11)
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner: jstolarek
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: th/T10945
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1344
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Jan Stolarek

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1344 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => fixed Comment: The test is passing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10945: Typed Template Haskell splices broken in HEAD (7.11)
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner: jstolarek
Type: bug | Status: closed
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.11
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: th/T10945
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1344
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10945: Typed Template Haskell splices broken in HEAD (7.11) -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: fixed | Keywords: | TypedTemplateHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T10945 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1344 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => TypedTemplateHaskell -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10945#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC