[commit: ghc] master: Fix #15385 by using addDictsDs in matchGuards (9d388eb)

git at git.haskell.org git at git.haskell.org
Mon Jul 30 12:55:56 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9d388eb83e797fd28e14868009c4786f3f1a8aa6/ghc

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

commit 9d388eb83e797fd28e14868009c4786f3f1a8aa6
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
    
    Summary:
    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


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

9d388eb83e797fd28e14868009c4786f3f1a8aa6
 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 9d388eb83e797fd28e14868009c4786f3f1a8aa6


More information about the ghc-commits mailing list