Opened 19 months ago

Last modified 18 months ago

#7241 new bug

GHC-7.6.1 panics on template haskell code

Reported by: akamaus Owned by: simonpj
Priority: normal Milestone: 7.8.3
Component: Template Haskell Version: 7.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

While experimenting with TH I stumbled upon a repeating compiler panic. After minifying I got this example which triggers the failure:

% cat Peekler.hs
module Peekler where

import Language.Haskell.TH

tst = do
  o <- newName "Foo"
  return $ [DataD [] o [] [RecC o []] [''Show]]
% cat PeeklerTest.hs
module PeeklerTest where

import Peekler

$(tst)

test = print Foo
% ghci -XTemplateHaskell PeeklerTest.hs             
GHCi, version 7.6.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 2] Compiling Peekler          ( Peekler.hs, interpreted )
[2 of 2] Compiling PeeklerTest      ( PeeklerTest.hs, interpreted )
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.1 for i386-unknown-linux):
        lookupExactOcc
<<details unavailable>>

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

> 
Leaving GHCi.
% ghc  -XTemplateHaskell PeeklerTest.hs
[1 of 2] Compiling Peekler          ( Peekler.hs, Peekler.o )
[2 of 2] Compiling PeeklerTest      ( PeeklerTest.hs, PeeklerTest.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.1 for i386-unknown-linux):
        lookupExactOcc
    Foo_a18S{tc}
    [main:PeeklerTest.Foo{tc a18S} defined at PeeklerTest.hs:5:3,
     main:PeeklerTest.Foo{d a18S} defined at PeeklerTest.hs:5:3]

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.1 LTS
Release:        12.04
Codename:       precise

Change History (2)

comment:1 Changed 19 months ago by simonpj

  • Difficulty set to Unknown

Thanks. You are defining the same precise name twice:

  data Foo_79 = Foo_79

where Foo_79 is the exact name. This is bad, because you are defining the same name twice. You probably intended mkName rather than newName.

But GHC shouldn't crash, and I will fix that. Thanks.

Simon

comment:2 Changed 18 months ago by igloo

  • Component changed from Compiler to Template Haskell
  • Milestone set to 7.8.1
  • Owner set to simonpj
Note: See TracTickets for help on using tickets.