Opened 8 years ago

Closed 8 years ago

Last modified 15 months ago

#1065 closed merge (fixed)

The impossible happened (Template Haskell)

Reported by: sfh23@… Owned by: simonpj
Priority: normal Milestone: 6.6.1
Component: Template Haskell Version: 6.6
Keywords: Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Test Case: TH_dataD1
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description (last modified by simonpj)

Error message during compilation:

ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for i386-unknown-linux):
        addImpDecls

This occurrs with the following function definition:

makeRowContent :: String -> [(String, SqlDecl)] -> Q [Dec]
makeRowContent tblName lst = do
  [d| data Tbl = Tbl
      instance TableContent Tbl where
        tableName Tbl = $(litE $ StringL tblName)
      $(dataD [] (mkName "Row") [] [recC "Row" []] [])
      instance RowContent Row where
        rowValueString x = "rowValue"
        rowNameString x = "rowName"
        tblName x = $(litE $ StringL tblName) |]

Change History (7)

comment:1 Changed 8 years ago by simonpj

  • Component changed from Compiler to Template Haskell
  • Description modified (diff)

I asked the submitter for a repo case. Simon

comment:2 Changed 8 years ago by sfh23@…

Compiling this module will replicate the problem:

module Main where

makeRowContent :: String -> Q [Dec]
makeRowContent tblName = do
  [d| data Tbl = Tbl
      instance TableContent Tbl where
        tableName Tbl = $(litE $ StringL tblName)
      $(dataD [] (mkName "Row") [] [recC "Row" []] [])
      instance RowContent Row where
        rowValueString x = "rowValue"
        rowNameString x = "rowName"
        tblName x = $(litE $ StringL tblName) |]

comment:3 Changed 8 years ago by igloo

  • Milestone set to 6.6.1
  • Owner set to simonpj
  • Test Case set to TH_dataD1

Thanks for the report; it looks like it's the $(dataD ... line causing the problems. I've put the minimal case in the testsuite (TH_dataD1).

Ian

comment:4 Changed 8 years ago by simonpj

  • Type changed from bug to merge

I've fixed the crash. Now it fails tidily instead with

TH_dataD1.hs:8:12:
    Declaration splices are not permitted inside declaration brackets

It's pretty tricky to lift this restriction, and I don't think it's important enough to invest a lot of time in right now.

Simon

Please merge this:
Fri Mar 23 11:19:12 GMT 2007 simonpj@…

  • Emit a decent error message when there is a decl-splice inside a decl-bracket

And please update the expected output in the test -- it's a "should-fail".

comment:5 Changed 8 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Merged, and test updated in both branches.

comment:6 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:7 Changed 15 months ago by Ian Lynagh <igloo@…>

In a7d78464091e048c25bdd85e98b10f958abe7156/ghc:

Add test TH_dataD1 for trac #1065
Note: See TracTickets for help on using tickets.