[commit: ghc] ghc-8.6: Fix #15385 by using addDictsDs in matchGuards (e649085)

git at git.haskell.org git at git.haskell.org
Thu Aug 2 02:42:43 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/e649085bb35628e10b08a9a1ef27095ad0510b40/ghc

>---------------------------------------------------------------

commit e649085bb35628e10b08a9a1ef27095ad0510b40
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Mon Jul 30 08:47:39 2018 -0400

    Fix #15385 by using addDictsDs in matchGuards
    
    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
    
    (cherry picked from commit 9d388eb83e797fd28e14868009c4786f3f1a8aa6)


>---------------------------------------------------------------

e649085bb35628e10b08a9a1ef27095ad0510b40
 compiler/deSugar/Check.hs                        |  2 +-
 compiler/deSugar/DsGRHSs.hs                      | 49 +++++++-----------------
 compiler/deSugar/DsUtils.hs                      | 32 +++++++++++++++-
 compiler/deSugar/Match.hs-boot                   |  4 +-
 compiler/hsSyn/HsPat.hs                          |  2 +-
 testsuite/tests/pmcheck/should_compile/T15385.hs | 21 ++++++++++
 testsuite/tests/pmcheck/should_compile/all.T     |  2 +
 7 files changed, 72 insertions(+), 40 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e649085bb35628e10b08a9a1ef27095ad0510b40


More information about the ghc-commits mailing list