[GHC] #10769: Yet another crash from type holes

GHC ghc-devs at haskell.org
Wed Aug 12 16:04:15 UTC 2015


#10769: Yet another crash from type holes
-----------------------------------------+-------------------------------
              Reporter:  rpglover64      |             Owner:
                  Type:  bug             |            Status:  new
              Priority:  normal          |         Milestone:  7.10.3
             Component:  Compiler        |           Version:  7.10.2
              Keywords:                  |  Operating System:  Linux
          Architecture:  x86_64 (amd64)  |   Type of failure:  GHCi crash
             Test Case:                  |        Blocked By:
              Blocking:                  |   Related Tickets:
Differential Revisions:                  |
-----------------------------------------+-------------------------------
 {{{#!hs
 {-# OPTIONS_GHC -fdefer-typed-holes #-}

 hylo a b = h where h = b . fmap h . a

 foo a b = hylo a' b'
   where a' x = _
         b' = _

 bar :: [Int]
 bar = []

 main = print bar
 }}}

 Loading this up in ghci and attempting to run main prints:

 {{{
 GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
 unknown option: 'c'
 [1 of 1] Compiling Main             ( bad.hs, interpreted )

 bad.hs:6:16: Warning:
     Found hole ‘_’ with type: t4
     Where: ‘t4’ is a rigid type variable bound by
                 the inferred type of a' :: t3 -> t4 at bad.hs:6:9
     Relevant bindings include
       x :: t3 (bound at bad.hs:6:12)
       a' :: t3 -> t4 (bound at bad.hs:6:9)
       b' :: forall t. t (bound at bad.hs:7:9)
       b :: t1 (bound at bad.hs:5:7)
       a :: t (bound at bad.hs:5:5)
       foo :: t -> t1 -> t2 -> b (bound at bad.hs:5:1)
     In the expression: _
     In an equation for ‘a'’: a' x = _
     In an equation for ‘foo’:
         foo a b
           = hylo a' b'
           where
               a' x = _
               b' = _

 bad.hs:7:14: Warning:
     Found hole ‘_’ with type: t3
     Where: ‘t3’ is a rigid type variable bound by
                 the inferred type of b' :: t3 at bad.hs:7:9
     Relevant bindings include
       b' :: t3 (bound at bad.hs:7:9)
       b :: t1 (bound at bad.hs:5:7)
       a :: t (bound at bad.hs:5:5)
       foo :: t -> t1 -> t2 -> b (bound at bad.hs:5:1)
     In the expression: _
     In an equation for ‘b'’: b' = _
     In an equation for ‘foo’:
         foo a b
           = hylo a' b'
           where
               a' x = _
               b' = _
 Ok, modules loaded: Main.
 *Main> main
 ghc: panic! (the 'impossible' happened)
   (GHC version 7.10.2 for x86_64-unknown-linux):
         nameModule $dFunctor_aKj

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

 }}}

 Compiling with ghc and then running the resulting binary works.

 Attempting to replicate with a recent version of GHC HEAD gives

 {{{
 GHCi, version 7.11.20150812: http://www.haskell.org/ghc/  :? for help
 unknown option: 'c'
 [1 of 1] Compiling Main             ( bad.hs, interpreted )

 bad.hs:5:11: error:
     No instance for (Functor f0) arising from a use of ‘hylo’
     The type variable ‘f0’ is ambiguous
     Note: there are several potential instances:
       instance Functor Maybe -- Defined in ‘GHC.Base’
       instance Functor IO -- Defined in ‘GHC.Base’
       instance Functor ((->) r) -- Defined in ‘GHC.Base’
       ...plus two others
     In the expression: hylo a' b'
     In an equation for ‘foo’:
         foo a b
           = hylo a' b'
           where
               a' x = _
               b' = _
 Failed, modules loaded: none.
 }}}

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


More information about the ghc-tickets mailing list