Skip to content
  • Simon Peyton Jones's avatar
    4d0e6da1
    Fix two bugs in short-cut constraint solving · 4d0e6da1
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    There are two main changes here:
    
    * Use `isSolvedWC` rather than `isEmptyWC` in `tryShortCutSolver`
      The residual constraint may have some fully-solved, but
      still-there implications, and we don't want them to abort short
      cut solving!  That bug caused #26805.
    
    * In the short-cut solver, we abandon the fully-solved residual
      constraint; but we may thereby lose track of Givens that are
      needed, and either report them as redundant or prune evidence
      bindings that are in fact needed.
    
      This bug stopped the `constraints` package from compiling;
      see the trail in !15389.
    
    The second bug led me to (another) significant refactoring
    of the mechanism for tracking needed EvIds.   See the new
       Note [Tracking needed EvIds] in GHC.Tc.Solver.Solve
    It's simpler and much less head-scratchy now.
    
    Some particulars:
    
    * An EvBindsVar now tracks NeededEvIds
    
    * We deal with NeededEvIds for an implication only when it is
      fully solved.  Much simpler!
    
    * `tryShortCutTcS` now takes a `TcM WantedConstraints` rather than
      `TcM Bool`, so that is can plumb the needed EvIds correctly.
    
    * Remove `ic_need` and `ic_need_implic` from Implication (hooray),
      and add `ics_dm` and `ics_non_dm` to `IC_Solved`.
    
    Pure refactor
    * Shorten data constructor `CoercionHole` to `CH`, following
      general practice in GHC.
    * Rename `EvBindMap` to `EvBindsMap` for consistency
    4d0e6da1
    Fix two bugs in short-cut constraint solving
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    There are two main changes here:
    
    * Use `isSolvedWC` rather than `isEmptyWC` in `tryShortCutSolver`
      The residual constraint may have some fully-solved, but
      still-there implications, and we don't want them to abort short
      cut solving!  That bug caused #26805.
    
    * In the short-cut solver, we abandon the fully-solved residual
      constraint; but we may thereby lose track of Givens that are
      needed, and either report them as redundant or prune evidence
      bindings that are in fact needed.
    
      This bug stopped the `constraints` package from compiling;
      see the trail in !15389.
    
    The second bug led me to (another) significant refactoring
    of the mechanism for tracking needed EvIds.   See the new
       Note [Tracking needed EvIds] in GHC.Tc.Solver.Solve
    It's simpler and much less head-scratchy now.
    
    Some particulars:
    
    * An EvBindsVar now tracks NeededEvIds
    
    * We deal with NeededEvIds for an implication only when it is
      fully solved.  Much simpler!
    
    * `tryShortCutTcS` now takes a `TcM WantedConstraints` rather than
      `TcM Bool`, so that is can plumb the needed EvIds correctly.
    
    * Remove `ic_need` and `ic_need_implic` from Implication (hooray),
      and add `ics_dm` and `ics_non_dm` to `IC_Solved`.
    
    Pure refactor
    * Shorten data constructor `CoercionHole` to `CH`, following
      general practice in GHC.
    * Rename `EvBindMap` to `EvBindsMap` for consistency
Loading