[GHC] #15598: RebindableSyntax with RankNTypes and type class method call yields panic.

GHC ghc-devs at haskell.org
Mon Sep 3 15:36:34 UTC 2018


#15598: RebindableSyntax with RankNTypes and type class method call yields panic.
-------------------------------------+-------------------------------------
        Reporter:  romanb            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
                                     |  RebindableSyntax, RankNTypes
Operating System:  Linux             |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  14963             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by romanb:

Old description:

> The following program in a file `ghc-panic.hs`
>
> {{{#!hs
>
> {-# LANGUAGE
>     GADTSyntax
>   , RankNTypes
>   , RebindableSyntax
> #-}
>
> import Prelude hiding ((>>=))
>
> data InfDo where
>     InfDo :: String -> (forall a. a -> InfDo) -> InfDo
>
> prog :: InfDo
> prog = do
>     _ <- show (42 :: Int)
>     prog
>   where
>     (>>=) = InfDo
>
> main :: IO ()
> main = let x = prog in x `seq` return ()
> }}}
>
> when loaded into GHCi yields
>
> {{{
> λ> main
> ghc: panic! (the 'impossible' happened)
>   (GHC version 8.4.3 for x86_64-unknown-linux):
>         nameModule
>   system $dShow_abfY
>   Call stack:
>       CallStack (from HasCallStack):
>         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
> ghc:Outputable
>         pprPanic, called at compiler/basicTypes/Name.hs:241:3 in ghc:Name
> }}}
>
> and separate compilation yields
>
> {{{
> $ ghc ghc-panic.hs
> [1 of 1] Compiling Main             ( ghc-panic.hs, ghc-panic.o )
> ghc: panic! (the 'impossible' happened)
>   (GHC version 8.4.3 for x86_64-unknown-linux):
>         StgCmmEnv: variable not found
>   $dShow_a1qI
>   local binds for:
>   $tcInfDo
>   $trModule
>   $tcInfDo1_r1th
>   $tcInfDo2_r1tH
>   $trModule1_r1tI
>   $trModule2_r1tJ
>   $trModule3_r1tK
>   $trModule4_r1tL
>   sat_s1E4
>   Call stack:
>       CallStack (from HasCallStack):
>         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
> ghc:Outputable
>         pprPanic, called at compiler/codeGen/StgCmmEnv.hs:149:9 in
> ghc:StgCmmEnv
> }}}
>
> The problem disappears when either the rank-2 type is removed from
> `InfDo` or when the call to `show` is replaced by a static string.
>
> Besides 8.4.3, also reproduced with 8.6.0.20180714

New description:

 The following program in a file `ghc-panic.hs`

 {{{#!hs

 {-# LANGUAGE
     GADTSyntax
   , RankNTypes
   , RebindableSyntax
 #-}

 import Prelude hiding ((>>=))

 data InfDo where
     InfDo :: String -> (forall a. a -> InfDo) -> InfDo

 prog :: InfDo
 prog = do
     _ <- show (42 :: Int)
     prog
   where
     (>>=) = InfDo

 main :: IO ()
 main = let x = prog in x `seq` return ()
 }}}

 when loaded into GHCi yields

 {{{
 λ> main
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.4.3 for x86_64-unknown-linux):
         nameModule
   system $dShow_abfY
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
 ghc:Outputable
         pprPanic, called at compiler/basicTypes/Name.hs:241:3 in ghc:Name
 }}}

 and separate compilation yields

 {{{
 $ ghc ghc-panic.hs
 [1 of 1] Compiling Main             ( ghc-panic.hs, ghc-panic.o )
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.4.3 for x86_64-unknown-linux):
         StgCmmEnv: variable not found
   $dShow_a1qI
   local binds for:
   $tcInfDo
   $trModule
   $tcInfDo1_r1th
   $tcInfDo2_r1tH
   $trModule1_r1tI
   $trModule2_r1tJ
   $trModule3_r1tK
   $trModule4_r1tL
   sat_s1E4
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
 ghc:Outputable
         pprPanic, called at compiler/codeGen/StgCmmEnv.hs:149:9 in
 ghc:StgCmmEnv
 }}}

 The problem disappears when either the rank-2 type is removed from `InfDo`
 or when the call to `show` is replaced by a static string.

 Besides 8.4.3, also reproduced with 8.6.0.20180714.

 I believe it is somewhat related to
 [https://ghc.haskell.org/trac/ghc/ticket/14963]

--

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


More information about the ghc-tickets mailing list