[commit: ghc] master: Take strict fields into account in coverage checking (744b034)

git at git.haskell.org git at git.haskell.org
Mon Aug 27 13:39:44 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/744b034dc2ea5b7b82b5586a263c12f231e803f1/ghc

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

commit 744b034dc2ea5b7b82b5586a263c12f231e803f1
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Mon Aug 27 14:05:45 2018 +0200

    Take strict fields into account in coverage checking
    
    Summary:
    The current pattern-match coverage checker implements the
    formalism presented in the //GADTs Meet Their Match// paper in a
    fairly faithful matter. However, it was discovered recently that
    there is a class of unreachable patterns that
    //GADTs Meet Their Match// does not handle: unreachable code due to
    strict argument types, as demonstrated in #15305. This patch
    therefore goes off-script a little and implements an extension to
    the formalism presented in the paper to handle this case.
    
    Essentially, when determining if each constructor can be matched on,
    GHC checks if its associated term and type constraints are
    satisfiable. This patch introduces a new form of constraint,
    `NonVoid(ty)`, and checks if each constructor's strict argument types
    satisfy `NonVoid`. If any of them do not, then that constructor is
    deemed uninhabitable, and thus cannot be matched on. For the full
    story of how this works, see
    `Note [Extensions to GADTs Meet Their Match]`.
    
    Along the way, I did a little bit of much-needed refactoring. In
    particular, several functions in `Check` were passing a triple of
    `(ValAbs, ComplexEq, Bag EvVar)` around to represent a constructor
    and its constraints. Now that we're adding yet another form of
    constraint to the mix, I thought it appropriate to turn this into
    a proper data type, which I call `InhabitationCandidate`.
    
    Test Plan: make test TEST=T15305
    
    Reviewers: simonpj, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: rwbarton, carter
    
    GHC Trac Issues: #15305
    
    Differential Revision: https://phabricator.haskell.org/D5087


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

744b034dc2ea5b7b82b5586a263c12f231e803f1
 compiler/deSugar/Check.hs                          | 317 +++++++++++++++++----
 docs/users_guide/8.8.1-notes.rst                   |  13 +
 testsuite/tests/pmcheck/should_compile/T15305.hs   |  58 ++++
 .../tests/pmcheck/should_compile/T15305.stderr     |   4 +
 testsuite/tests/pmcheck/should_compile/all.T       |   2 +
 .../tests/simplCore/should_compile/T13990.stderr   |   4 +
 6 files changed, 338 insertions(+), 60 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 744b034dc2ea5b7b82b5586a263c12f231e803f1


More information about the ghc-commits mailing list