Skip to content

More informative assertion for non-unique TH names

Let's say that by accident I have duplicated uniques of Template Haskell built-in identifiers defined in THNames module:

returnQIdKey        = mkPreludeMiscIdUnique 200
bindQIdKey          = mkPreludeMiscIdUnique 200

If I have a debugging build (-DDEBUG) and start a GHCi session it crashes immediately with a very uninformative error message:

GHCi, version 7.11.20150903: http://www.haskell.org/ghc/  :? for help

<interactive>:1:1: error:
    Bad interface file: /dane/projekty/ghc/build/libraries/base/dist-install/build/Prelude.hi
        ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.11.20150903 for x86_64-unknown-linux):
        ASSERT failed!
<<details unavailable>>

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

I have no idea where this assertion comes from as it gives absolutely no clue as to what caused the problem. During ICFP this costed me and Richard a total of around 6 man-hours. We should replace that assertion with something more meaningful. One thing we could do is add an assertion to the definition of THNames.templateHaskellNames that makes sure that length templateHaskellNames == length (nub templateHaskellNames). That by itself is very simple but the problem is that the uninformative assertion given above still kicks in first.

Trac metadata
Trac field Value
Version 7.11
Type Task
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information