• Ryan Scott's avatar
    Fix #15385 by using addDictsDs in matchGuards · 9d388eb8
    Ryan Scott authored
    When coverage checking pattern-matches, we rely on the call
    sites in the desugarer to populate the local dictionaries and term
    evidence in scope using `addDictsDs` and `addTmCsDs`. But it turns
    out that only the call site for desugaring `case` expressions was
    actually doing this properly. In another part of the desugarer,
    `matchGuards` (which handles pattern guards), it did not update the
    local dictionaries in scope at all, leading to #15385.
    Fixing this is relatively straightforward: just augment the
    `BindStmt` case of `matchGuards` to use `addDictsDs` and `addTmCsDs`.
    Accomplishing this took a little bit of import/export tweaking:
    * We now need to export `collectEvVarsPat` from `HsPat.hs`.
    * To avoid an import cycle with `Check.hs`, I moved `isTrueLHsExpr`
      from `DsGRHSs.hs` to `DsUtils.hs`, which resides lower on the
      import chain.
    Test Plan: make test TEST=T15385
    Reviewers: simonpj, bgamari
    Reviewed By: simonpj
    Subscribers: rwbarton, thomie, carter
    GHC Trac Issues: #15385
    Differential Revision: https://phabricator.haskell.org/D4968
Match.hs-boot 824 Bytes