[GHC] #9255: Exception when DeriveFunctor fails

GHC ghc-devs at haskell.org
Mon Jun 30 17:45:42 UTC 2014


#9255: Exception when DeriveFunctor fails
-----------------------------------+---------------------------------------
       Reporter:  twanvl           |             Owner:
           Type:  bug              |            Status:  new
       Priority:  low              |         Milestone:
      Component:  Compiler         |           Version:  7.8.1
       Keywords:                   |  Operating System:  Unknown/Multiple
   Architecture:                   |   Type of failure:  Compile-time crash
  Unknown/Multiple                 |         Test Case:
     Difficulty:  Unknown          |          Blocking:
     Blocked By:                   |
Related Tickets:                   |
-----------------------------------+---------------------------------------
 The following program
 {{{
 {-# LANGUAGE DeriveFunctor #-}

 data Foo a = Foo
 data Bar a = Bar [Foo a]
   deriving (Functor)
 }}}

 Gives the error message
 {{{
 foo.hs:5:13:ghc: panic! (the 'impossible' happened)
   (GHC version 7.8.1 for x86_64-unknown-linux):
         Prelude.(!!): index too large
 }}}
 While it should give
 {{{
 foo.hs:4:13:No instance for (Functor Foo)
 }}}

 The use of `[]` in `[Foo a]` is not essential, it can be any type
 constructor that is an instance of Functor. Without the extra type
 constructor an error is correctly reported.

 The cause seems to be in the error message. If it wraps to the next line,
 then ghc dies with:
 {{{
 foo-with-a-longer-filename.hs:5:13:
     No instance for (Functorghc: panic! (the 'impossible' happened)
 }}}

 When using stand alone deriving ghc does not crash.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9255>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list