Opened 10 months ago

Last modified 14 hours ago

#9160 new bug

Panic: Template variable unbound in rewrite rule

Reported by: mietek Owned by:
Priority: normal Milestone: 7.8.3
Component: Compiler Version: 7.8.2
Keywords: Cc: jstolarek, slyfox, george
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case: indexed_types/should_fail/T9160
Blocked By: Blocking:
Related Tickets: #4524 Differential Revisions:

Description (last modified by mietek)

Installing singletons-1.0 with GHC 7.8.2 on both OS X 10.9.2 and Ubuntu 2014.04 fails:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.8.2 for x86_64-apple-darwin):
        Template variable unbound in rewrite rule

This seems to be an issue with the optimizer, as the bug only appears with optimization level 2, using the following line in ~/.cabal/config:

optimization: 2

See also goldfirere/singletons#83

Attachments (4)

singletons-1.0.log (10.4 KB) - added by mietek 10 months ago.
Build log
ghc.info (1.7 KB) - added by mietek 10 months ago.
ghc --info
singletons-1.0-build.log (9.5 KB) - added by mjo 5 months ago.
ghc-info.txt (1.8 KB) - added by mjo 5 months ago.

Download all attachments as: .zip

Change History (18)

Changed 10 months ago by mietek

Build log

comment:1 Changed 10 months ago by mietek

comment:2 Changed 10 months ago by mietek

Changed 10 months ago by mietek

ghc --info

comment:3 Changed 10 months ago by mietek

  • Description modified (diff)

comment:4 Changed 10 months ago by mietek

  • Operating System changed from MacOS X to Unknown/Multiple

comment:5 Changed 10 months ago by mietek

  • Description modified (diff)

comment:6 Changed 10 months ago by Simon Peyton Jones <simonpj@…>

In b637585dcbfc1ba53aa49bcb9b730cd08fea4b59/ghc:

Fix elemLocalRdrEnv (Trac #9160)

This was pretty obscure.  elemLocalRdrEnv was utterly wrong (replied
False when it should reply True) when given an Exact Name. That
doesn't happen often, but it does happen in the result of a TH splice.
The result was that an associated type didn't get a type variable that
lined up with its parent class (elemLocalRdrEnv is used in
RnTypes.bindHsTyVars), and that messed up the singletons package.

I've made a completely different test case to show up the bug:
indexed_types/should_fail/T9160

I also refactored RdrName.LocalRdrEnv to be a record with named
fields, which makes the code more robust and easy to understand.

comment:7 Changed 10 months ago by simonpj

  • Status changed from new to merge
  • Test Case set to indexed_types/should_fail/T9160

comment:8 Changed 9 months ago by thoughtpolice

  • Milestone set to 7.8.3

comment:9 Changed 9 months ago by thoughtpolice

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

Merged into 7.8.3.

comment:10 Changed 5 months ago by mjo

  • Resolution fixed deleted
  • Status changed from closed to new

I'm seeing the same symptoms with 7.8.3:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3

Only with -O2 set, again.

$ cd singletons-1.0/
$ runghc Setup.hs configure --user -O2
Configuring singletons-1.0...
$ runghc Setup.hs build
...
[39 of 45] Compiling Data.Singletons.Prelude.List ( src/Data/Singletons/Prelude/List.hs, dist/build/Data/Singletons/Prelude/List.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.8.3 for x86_64-unknown-linux):
	Template variable unbound in rewrite rule

Changed 5 months ago by mjo

Changed 5 months ago by mjo

comment:11 Changed 5 months ago by mjo

I should also mention that the test cases passes, i.e. fails:

$ ghc T9160.hs
[1 of 1] Compiling T9160            ( T9160.hs, T9160.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.

T9160.hs:18:8:
    Type indexes must match class instance head
    Found ‘* -> *’ but expected ‘*’
    In the type instance declaration for ‘F’
    In the instance declaration for ‘C (a :: *)’

Same thing happens with -O2.

comment:12 Changed 7 weeks ago by slyfox

  • Cc slyfox added

comment:13 Changed 14 hours ago by George

I am also seeing this on ghc 7.10.1, not sure if this is another instance of this bug:

cabal install bitmap
[ 3 of 10] Compiling Data.Bitmap.IO ( Data/Bitmap/IO.hs, dist/build/Data/Bitmap/IO.o )

Data/Bitmap/IO.hs:1248:1: Warning:

SPECIALISE pragma for non-overloaded function ‘myPlusPtr’

Data/Bitmap/IO.hs:1249:1: Warning:

SPECIALISE pragma for non-overloaded function ‘myPlusPtr’

ghc: panic! (the 'impossible' happened)

(GHC version 7.10.1 for x86_64-apple-darwin):

Template variable unbound in rewrite rule

$fPixelComponentFloat3_X2Rc
[$fPixelComponentFloat3_X2Rc]
[$fPixelComponentFloat3_X2Rc]
[]
[]

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

Last edited 14 hours ago by George (previous) (diff)

comment:14 Changed 14 hours ago by George

  • Cc george added
Note: See TracTickets for help on using tickets.