[GHC] #12991: panic when using IrredPreds in a type checker plugin.

GHC ghc-devs at haskell.org
Fri Dec 16 14:56:15 UTC 2016


#12991: panic when using IrredPreds in a type checker plugin.
-------------------------------------+-------------------------------------
           Reporter:  owen           |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Compile-time
  Unknown/Multiple                   |  crash or panic
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I'm working on a type checker plugin that solves constraints expressed
 with an empty, closed type family of kind Constraint.  These show up in
 the plugin as wanted IrredPred constraints.  Unfortunately, something
 seems to go sideways sometimes when I give solved or unsolvable IrredPreds
 back to GHC.

 I've managed to reproduce the error in a minimal-ish plugin.  It doesn't
 try to solve anything, it just returns all the IrredPred constraints back
 to GHC in a TcPluginContradiction.  When compiling a test case that uses
 the type family in a constraint, it gives the following output:
 {{{
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.0.1 for x86_64-apple-darwin):
         StgCmmEnv: variable not found
   $dMonad_a5fm
   local binds for:
   $trModule
   $trModule1_r5qI
   $trModule2_r5rc
 }}}

 If I omit the IrredPreds and return an empty TcPluginContradiction, I get
 'Could not deduce...' errors as I would expect.
 Strangley, the panic also goes away if I give an explicit type signature
 to main in the test case.  I'm attaching an archive with 3 files.
 Plugin.hs has the plugin itself.  Compare.hs has the closed type family.
 The test case that exercises the panic is in Fails.hs.  Running
 {{{
 ghc  -shared -dynamic --make Test/*.hs -package ghc-8.0.1
 }}}
 in the unpacked directory should reproduce the panic. Adding -dcore-lint
 does give some potentially useful information:
 {{{
 [3 of 3] Compiling Test.Fails       ( Test/Fails.hs, Test/Fails.o )
 irred compare
   [W] irred_a5qq :: l_a5fo[tau:3] ≽ l'_a5fp[tau:3] (CNonCanonical)
 irred compare
   [W] irred_a5qr :: l'_a5fp[tau:3] ≽ l_a5fo[tau:3] (CNonCanonical)
 <no location info>: warning:
     In the expression: return @ m_a5fl $dMonad_a5fm @ ()
     $dMonad_a5fm :: Monad m_a5fl[tau:3]
     [LclId, Str=DmdType] is out of scope
 <no location info>: warning:
     In the expression: (irred_a5qq, irred_a5qr)
     irred_a5qq :: s_a5ql[fuv:2]
     [LclId, Str=DmdType] is out of scope
 <no location info>: warning:
     In the expression: (irred_a5qq, irred_a5qr)
     Argument value doesn't match argument type:
     Fun type:
         (Integer ≽ Integer, Integer ≽ Integer) =>
         (Integer ≽ Integer, Integer ≽ Integer)
     Arg type: s_a5ql[fuv:2]
     Arg: irred_a5qq
 *** Offending Program ***
 $trModule :: Module
 [LclIdX, Str=DmdType]
 $trModule = Module (TrNameS "main"#) (TrNameS "Test.Fails"#)

 oops
   :: forall l_a572 l'_a573.
      (l_a572 === l'_a573) =>
      l_a572 -> l'_a573 -> ()
 [LclIdX, Str=DmdType]
 oops =
   \ (@ l_a5eW) (@ l'_a5eX) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] ->
     ()

 main :: forall (m_a5fl :: * -> *). m_a5fl ()
 [LclIdX, Str=DmdType]
 main =
   \ (@ (m_a5fl :: * -> *)) ->
     $ @ 'PtrRepLifted
       @ ()
       @ (m_a5fl ())
       (return @ m_a5fl $dMonad_a5fm @ ())
       (oops @ Integer @ Integer (irred_a5qq, irred_a5qr) 1 0)

 *** End of Offense ***


 <no location info>: error:
 Compilation had errors
 }}}

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


More information about the ghc-tickets mailing list