Skip to content
  • Simon Peyton Jones's avatar
    Do not add a 'solved dict' for quantified constraints · 226d86d2
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    GHC has a wonderful-but-delicate mechanism for building recursive
    dictionaries by adding a goal to the "solved dictionaries" before
    solving the sub-goals.  See Note [Solved dictionaries] in TcSMonad
    
    Ticket #17267 showed that if you use this mechanism for local
    /quantified/ constraints you can get a loop -- or even unsafe
    coerce.   This patch fixes the bug.
    
    Specifically
    
    * Make TcSMonad.addSolvedDict be conditional on using a
      /top level/ instance, not a quantified one.
    
    * Moreover, we /also/ don't want to add a solved dict
      for equalities (a~b).
    
    * Add lots more comments to Note [Solved dictionaries]
      to explain the above cryptic stuff.
    
    * Extend InstanceWhat to identify those strange built-in
      equality instances.
    
    A couple of other things along the way
    
    * Delete the unused Type.isIPPred_maybe.
    
    * Stop making addSolvedDict conditional on not being an
      impolicit parameter.  This comes from way back. But
      it's irrelevant now because IP dicts are ...
    226d86d2