Opened 9 years ago

Closed 8 years ago

#2378 closed merge (fixed)

panic: lookupVers1, when standalone deriving Typeable and Data

Reported by: guest Owned by:
Priority: normal Milestone: 6.8 branch
Component: Compiler Version: 6.8.3
Keywords: Cc: benedikt.huber@…, claus
Operating System: MacOS X Architecture: x86
Type of failure: None/Unknown Test Case: deriving/should_compile/T2378
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When using StandaloneDeriving and DeriveDataTypeable on a rather large AST, occasionally GHC 6.8.2 and GHC 6.8.3 RC bail with

[13 of 24] Compiling Language.C.AST.Generic
ghc- panic! (the 'impossible' happened)
  (GHC version for i386-apple-darwin):
        lookupVers1 language-c-test-0.2:Language.C.AST.Constants $cFlags{v}

Please report this as a GHC bug:

This is probably related to ticket #2011 (marked as milestone 6.8.3), clean and rebuild resolves the problem temporarily.

I haven't been able to extract a small test case, but the problematic source is available online at

The bug is reproducible: (cabal) build, comment out the last 6 'deriving Data' clauses (line 96-101), build again, uncomment, build again.

Side notes: There is a warning (but no error !) when deriving a Typeable1 instance (maybe related to #1825)

[13 of 24] Compiling Language.C.AST.Generic
Var/Type length mismatch: 
    [f{tv i1lc} [tv]]
... [as above]

Finally, in GHC 6.9 standalone deriving Data was unsupported as of 01042008:

[13 of 24] Compiling Language.C.AST.Generic
Illegal binding of built-in syntax: $cCHeader

Change History (8)

comment:1 Changed 9 years ago by claus

Cc: claus added

I'm running into the Illegal binding of built-in syntax issue (Windows, 6.9.20080514).

comment:2 Changed 9 years ago by simonpj

difficulty: Unknown
Owner: set to simonpj

This is bad. I'm looking into it.


comment:3 Changed 9 years ago by benedikt


The problem is also present in ghc-6.8.3.

I've put the (unfortunately rather large) test case online, including the compile log.

ghc2378(0) $ ghc -V
The Glorious Glasgow Haskell Compilation System, version 6.8.3
ghc2378(0) $ tail -n 8 compile.log 
*** Deleting temp dirs:
Deleting: /var/folders/Vz/VzXOgyLmGRapgKZSH9x4K++++TI/-Tmp-//ghc29958_0
ghc-6.8.3: panic! (the 'impossible' happened)
  (GHC version 6.8.3 for i386-apple-darwin):
        lookupVers1 main:Language.C.AST.Constants $cFlags{v}

Please report this as a GHC bug:

comment:4 Changed 9 years ago by simonpj

Nice program. You revealed at least three bugs in the implementation of standalone deriving, and that's without counting the lookupVers1 problem, which doesn't show up in HEAD.

So I've fixed all of them in the HEAD. Since we've pushed 6.8.3 out now, we've missed the boat on that. If we ever release 6.8.4 we should put the patch in:

Tue Jul  1 13:09:08 BST 2008
  * Several fixes to 'deriving' including Trac #2378

There's no good workaround for 6.8.3 except not to use standalone deriving. Also doing this:

newtype T f = ... deriving( Typeable1 )

seems unfixably broken in 6.8.3 I'm afraid. I think you may have to use a data type instead.

Thanks for bringing all this to light.


comment:5 Changed 9 years ago by simonpj

Owner: changed from simonpj to igloo
Test Case: deriving/should_compile/T2378
Type: bugmerge

Added a test for the newtype deriving thing. I was wrong above: the thing that is broken is standalone deriving for Typeable1 of newtype:

newtype T a = ...
deriving instance Typeable1 T

Also reclassifying as 'merge' so that Ian can keep it on his merge list for 6.8.4


comment:6 Changed 9 years ago by igloo

Milestone: 6.8 branch

comment:7 Changed 9 years ago by igloo

Owner: igloo deleted

comment:8 Changed 8 years ago by igloo

Resolution: fixed
Status: newclosed

We won't be releasing 6.8.4.

Note: See TracTickets for help on using tickets.