Ticket #4056 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

GHC panic with small TH code

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

Description (last modified by igloo) (diff)

[verdelyi@localhost CompilerGenerator-Haskell]$ cat BUG.hs 
{-# LANGUAGE TemplateHaskell, TypeFamilies, RankNTypes, FlexibleContexts #-}

import Language.Haskell.TH

astTest :: Q [Dec]
astTest = [d|
    generateWalker :: forall t . [t] -> [t]
    generateWalker = id

    class (Num (From t), Num (To t)) => TransformationPhase t where
        type From t
        type To t
        type Downwards t
        type Upwards t

        executeTransformationPhase :: [t] -> [t]
        executeTransformationPhase = undefined
  |]
[verdelyi@localhost CompilerGenerator-Haskell]$ ghci BUG.hs 
GHCi, version 6.12.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
[1 of 1] Compiling Main             ( BUG.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 6.12.2 for i386-unknown-linux):
	nameModule executeTransformationPhase{v agj}

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

> 

Change History

Changed 3 years ago by igloo

  • description modified (diff)

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to th/T4056
  • resolution set to fixed

Excellent point. Not quite as simple to fix as I thought! Thank you for letting us know.

Fixed by

Tue May 25 12:39:10 BST 2010  simonpj@microsoft.com
  * Refactor (again) the handling of default methods
  
  This patch fixes Trac #4056, by 
  
   a) tidying up the treatment of default method names
   b) removing the 'module' argument to newTopSrcBinder
  
  The details aren't that interesting, but the result
  is much tidier. The original bug was a 'nameModule' panic,
  caused by trying to find the module of a top-level name.
  But TH quotes generate Internal top-level names that don't
  have a module, and that is generally a good thing.  
  
  Fixing that in turn led to the default-method refactoring,
  which also makes the Name for a default method be handled
  in the same way as other derived names, generated in BuildTyCl
  via a call newImplicitBinder.  Hurrah.
Note: See TracTickets for help on using tickets.