Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
6376 commits behind the upstream repository.
  • Simon Peyton Jones's avatar
    226d86d2
    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 never solved
      via an instance.
    226d86d2
    History
    Do not add a 'solved dict' for quantified constraints
    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 never solved
      via an instance.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
T17267a.stderr 617 B