[commit: ghc] ghc-8.6: Fix #15450 by refactoring checkEmptyCase' (ebd773a)

git at git.haskell.org git at git.haskell.org
Thu Aug 2 00:36:42 UTC 2018


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

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

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

commit ebd773a09be134157880eaa1099f4b5d30a67aac
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Wed Aug 1 14:26:44 2018 -0400

    Fix #15450 by refactoring checkEmptyCase'
    
    `checkEmptyCase'` (the code path for coverage-checking
    `EmptyCase` expressions) had a fair bit of code duplication from the
    code path for coverage-checking non-`EmptyCase` expressions, and to
    make things worse, it behaved subtly different in some respects (for
    instance, emitting different warnings under unsatisfiable
    constraints, as shown in #15450). This patch attempts to clean up
    both this discrepancy and the code duplication by doing the
    following:
    
    * Factor out a `pmInitialTmTyCs` function, which returns the initial
      set of term and type constraints to use when beginning coverage
      checking. If either set of constraints is unsatisfiable, we use an
      empty set in its place so that we can continue to emit as many
      warnings as possible. (The code path for non-`EmptyCase`
      expressions was doing this already, but not the code path for
      `EmptyCase` expressions, which is the root cause of #15450.)
    
      Along the way, I added a `Note` to explain why we do this.
    * Factor out a `pmIsSatisfiable` constraint which checks if a set of
      term and type constraints are satisfiable. This does not change any
      existing behavior; this is just for the sake of deduplicating code.
    
    Test Plan: make test TEST=T15450
    
    Reviewers: simonpj, bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #15450
    
    Differential Revision: https://phabricator.haskell.org/D5017
    
    (cherry picked from commit 7f3cb50dd311caefb536d582f1e3d1b33d6650f6)


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

ebd773a09be134157880eaa1099f4b5d30a67aac
 compiler/deSugar/Check.hs                          | 137 +++++++++++++++------
 testsuite/tests/pmcheck/should_compile/T15450.hs   |   9 ++
 .../tests/pmcheck/should_compile/T15450.stderr     |  11 ++
 testsuite/tests/pmcheck/should_compile/all.T       |   2 +
 4 files changed, 119 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 ebd773a09be134157880eaa1099f4b5d30a67aac


More information about the ghc-commits mailing list