Exhaustiveness check for EmptyCase (Trac #10746)
authorGeorge Karachalias <george.karachalias@gmail.com>
Thu, 2 Feb 2017 18:51:33 +0000 (13:51 -0500)
committerBen Gamari <ben@smart-cactus.org>
Thu, 2 Feb 2017 19:20:45 +0000 (14:20 -0500)
commitb10353216f5ff5d5e410334e4c118b6695b628d0
tree3568dc551cc049e1c0a4901dbe76e062ef4b16ed
parentd8ac64e782b8543e5a525c7bb738620bd09aa398
Exhaustiveness check for EmptyCase (Trac #10746)

Empty case expressions have strict semantics so the problem boils down
to inhabitation checking for the type of the scrutinee. 3 main functions
added:

- pmTopNormaliseType_maybe for the normalisation of the scrutinee type

- inhabitationCandidates for generating the possible patterns of the
  appropriate type

- checkEmptyCase' to filter out the candidates that give rise to
  unsatisfiable constraints.

See Note [Checking EmptyCase Expressions] in Check
and Note [Type normalisation for EmptyCase] in FamInstEnv

Test Plan: validate

Reviewers: simonpj, goldfire, dfeuer, austin, bgamari

Reviewed By: bgamari

Subscribers: mpickering, thomie

Differential Revision: https://phabricator.haskell.org/D2105

GHC Trac Issues: #10746
26 files changed:
compiler/deSugar/Check.hs
compiler/types/FamInstEnv.hs
compiler/types/Type.hs
testsuite/tests/pmcheck/should_compile/EmptyCase001.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase002.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase003.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase004.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase005.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase006.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase007.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase008.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase009.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase010.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/T10746.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/T10746.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/all.T