[GHC] #9209: Template haskell panic

#9209: Template haskell panic ------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- I was trying to get some template haskell thing to work and was messing around and ran into this bug. Prelude> let $([d||]) ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): cvBindsAndSigs $[splice{v}]([d| |]) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Prelude> The following file: {-# LANGUAGE TemplateHaskell #-} let $([d||]) main = do return () gives the following error message: test.hs:3:1: parse error (possibly incorrect indentation or mismatched brackets) but doesn't crash. So it seems to be ghci-specific...? the other oxford brackets work fine (or don't suffer from exactly the same bug, anyway) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------ Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Description changed by tulcod: Old description:
I was trying to get some template haskell thing to work and was messing around and ran into this bug.
Prelude> let $([d||]) ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): cvBindsAndSigs $[splice{v}]([d| |])
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Prelude>
The following file: {-# LANGUAGE TemplateHaskell #-} let $([d||]) main = do return ()
gives the following error message:
test.hs:3:1: parse error (possibly incorrect indentation or mismatched brackets)
but doesn't crash. So it seems to be ghci-specific...?
the other oxford brackets work fine (or don't suffer from exactly the same bug, anyway)
New description: I was trying to get some template haskell thing to work and was messing around and ran into this bug. {{{ Prelude> let $([d||]) ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): cvBindsAndSigs $[splice{v}]([d| |]) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Prelude> }}} The following file: {{{ {-# LANGUAGE TemplateHaskell #-} let $([d||]) main = do return () }}} gives the following error message: {{{ test.hs:3:1: parse error (possibly incorrect indentation or mismatched brackets) }}} but doesn't crash. So it seems to be ghci-specific...? the other oxford brackets work fine (or don't suffer from exactly the same bug, anyway) -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------ Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): The problem here is that declaration splices are not yet allowed in `let`/`where`, but we aren't even giving a decent error message if one does show up there. Until the split between typed and untyped splices we ''couldn't'' have declaration splices except at top level, but now we definitely can. It just needs implementing. (Not hard; all the heavey lifting is done already.) Any volunteers? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------ Reporter: tulcod | Owner: archblob Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by archblob): * owner: => archblob Comment: I'll do it, I'll take a look at the code and write back if I have any questions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: archblob Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): I'm doing a bunch of TH bugfixes. @archblob, you still working on this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by archblob): * owner: archblob => Comment: No, you can take ownership. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): Not GHCi specific, but my guess is that `-XTemplateHaskell` was not enabled in the standalone example. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): While I'm at it, should I also allow "naked" expressions to be interpreted as splices in non-top-level contexts? I say "no", but am happy to hear others' opinions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I say "no". I rather doubt that it was a good decision to allow naked TH splices at top level! Let's not propagate it. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): I tend to agree about the weirdness of naked top-level expressions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): Instead of implementing spliced declarations in more contexts, I'm just going to fix the panic and turn it into a sensible error message. In contrast to Simon's comment:2, not all the heavy lifting is done. To implement declaration splices in other contexts, it will be necessary to make rather drastic changes to the relevant AST nodes: we would need, say, an `HsLocalBinds` now to store declarations in the order they were written, so we can use declaration splices to break up mutually recursive blocks, as we do at top level. The same would have to be done for classes and instances. This would add up to quite a lot of code change, for a feature no one has actually requested. (I'm taking the original report to be a complaint about a panic, not a complaint about a missing splice feature.) All of this ''is'' possible, but it's more work than I wish to invest at the moment. Expect a patch soon fixing the error message, but if you want non-top-level declaration splices, please create a new ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D429 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => patch * differential: => Phab:D429 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9209: Template haskell panic
-------------------------------------+-------------------------------------
Reporter: tulcod | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: | Blocked By:
None/Unknown | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: Phab:D429 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9209: Template haskell panic
-------------------------------------+-------------------------------------
Reporter: tulcod | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: | Blocked By:
None/Unknown | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: Phab:D429 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9209: Template haskell panic -------------------------------------+------------------------------------- Reporter: tulcod | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: th/T9209 | Blocking: | Differential Revisions: Phab:D429 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: patch => closed * testcase: => th/T9209 * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9209#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC