[GHC] #11379: Solver hits iteration limit in code without recursive constraints

GHC ghc-devs at haskell.org
Mon Jan 18 22:16:53 UTC 2016


#11379: Solver hits iteration limit in code without recursive constraints
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:  simonpj
            Type:  bug               |               Status:  closed
        Priority:  highest           |            Milestone:  8.0.1
       Component:  Compiler (Type    |              Version:  8.0.1-rc1
  checker)                           |
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by NeilMitchell):

 * cc: ndmitchell (added)


Comment:

 For info, I found a similar bug while trying Shake with GHC 8.0-rc1
 provided by hvr (8.0.0.20160111+git.0.497454f). Chopping out the relevant
 bit leaves:

 {{{#!hs
 -- optIntArg :: (Ord a0, Read a0, Show a0) => a0 -> [Char] -> t0 -> (Maybe
 a0 -> t2) -> Maybe String -> Either [Char] ([t1], t2)
 optIntArg mn flag a f = maybe (Right ([], f Nothing)) $ \x -> case reads x
 of
     [(i,"")] | i >= mn -> Right ([],f $ Just i)
     _ -> Left $ "the `--" ++ flag ++ "' option requires a number, " ++
 show mn ++ " or above"
 }}}

 Uncommenting the type signature makes it work. Without, it fails with:

 {{{
     solveWanteds: too many iterations (limit = 4)
       Unsolved: WC {wc_simple =
                       [D] _ :: Eq a (CDictCan)
                       [D] _ :: Ord a (CDictCan)
                       [D] _ :: Read a (CDictCan)
                       [D] _ :: Show a (CDictCan)
                       [W] hole{a5xW} :: a ~ a (CNonCanonical)
                       [D] _ :: Eq a (CDictCan)}
       New superclasses found
       Set limit with -fconstraint-solver-iterations=n; n=0 for no limit]
 }}}

 Given the size of the code fragment that triggers it, and the fact a
 number of bugs were found, this might be another useful test case.

 Tweaking to give:

 {{{#!hs
 optIntArg mn flag a f = maybe (Right ([], f Nothing)) $ \x -> case reads x
 of
     [(i,"")] | i == mn -> Right ([],f $ Just i)
     _ -> Left $ "the `--" ++ flag ++ "' option requires a number, or
 above"
 }}}

 I end up with a very different error:

 {{{
 src\Demo.hs:5:41: error:
     * Couldn't match type `a' with `a1'
         because type variable `a1' would escape its scope
       This (rigid, skolem) type variable is bound by
         a type expected by the context:
           Maybe a1
         at src\Demo.hs:5:37-46
       Expected type: Maybe a1
         Actual type: Maybe a
 }}}

 This code compiles fine with GHC 7.10, so seems like a different bug, or
 different manifestation of the same bug.

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


More information about the ghc-tickets mailing list