[GHC] #12734: Unexpected context reduction stack overflow

GHC ghc-devs at haskell.org
Tue Oct 18 11:04:44 UTC 2016


#12734: Unexpected context reduction stack overflow
-------------------------------------+-------------------------------------
           Reporter:  danilo2        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  high           |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Hello!
 I don't have a minimal example, but I've got a very clear strange
 bahavior:

 We've got a function:

 {{{
 nstar3 :: ( ExprCons t layers m, Bindable t m, Self.MonadSelfBuilder
 (Binding (Expr2 t layers AnyLayout)) m
           , ExprInferable t layers m)
        => m (Binding (PrimExpr2' t layers Star))
 nstar3 = Self.put . anyLayout2 =<<& (nstar2 >>= mkBinding)

 }}}

 If I use it in a different function and use following explicit type, I get
 the error:

 {{{
 test_gr3 :: ( ExprCons t layers m, Bindable t m, ExprInferable t layers m
             , MonadIO m, Show bind, Show (PrimExpr2' t layers Star),
 layers~'[Data, Type]
             , Self.MonadSelfBuilder (Binding (Expr2 t layers AnyLayout)) m
             , bind ~ Binding (PrimExpr2' t layers Star)
         ) => m bind
 test_gr3 = do
     sref <- nstar3
 }}}

 error (while using the function and evaluating monads):

 {{{
     • Reduction stack overflow; size = 201
       When simplifying the following type:
         MonadFix
           (Self.SelfBuilderT (Binding (Expr2 t0 '[Data, Type] AnyLayout))
 m)
       Use -freduction-depth=0 to disable this check
       (any upper bound you could choose might fail unpredictably with
        minor updates to GHC, so disabling the check is recommended if
        you're sure that type checking should terminate)
     • In the second argument of ‘($)’, namely ‘(test_gr3)’
       In the second argument of ‘($)’, namely
         ‘runInferenceT2 @TermType @Net $ (test_gr3)’
       In the second argument of ‘($)’, namely
         ‘runInferenceT2 @InfLayers @'[Data, Type]
          $ runInferenceT2 @TermType @Net $ (test_gr3)’

 }}}

 What is "funny" is that if I change the type of `test_gr3` to a very
 similar one, I just replace the part `=> m bind` with manually expanded
 one  `m (Binding (PrimExpr2' t layers Star))` everything compiles fine.

 It would be really hard to get minimal example out of it – it uses nested
 mfixes and will take much time to cut it down. The question is – can we
 locate the error based on the description?

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


More information about the ghc-tickets mailing list