[commit: ghc] master: COMPLETE pragmas for enhanced pattern exhaustiveness checking (1a3f1ee)
git at git.haskell.org
git at git.haskell.org
Thu Jan 26 00:23:10 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/1a3f1eebf81952accb6340252816211c7d391300/ghc
>---------------------------------------------------------------
commit 1a3f1eebf81952accb6340252816211c7d391300
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date: Wed Jan 18 13:25:30 2017 +0000
COMPLETE pragmas for enhanced pattern exhaustiveness checking
This patch adds a new pragma so that users can specify `COMPLETE` sets of
`ConLike`s in order to sate the pattern match checker.
A function which matches on all the patterns in a complete grouping
will not cause the exhaustiveness checker to emit warnings.
```
pattern P :: ()
pattern P = ()
{-# COMPLETE P #-}
foo P = ()
```
This example would previously have caused the checker to warn that
all cases were not matched even though matching on `P` is sufficient to
make `foo` covering. With the addition of the pragma, the compiler
will recognise that matching on `P` alone is enough and not emit
any warnings.
Reviewers: goldfire, gkaracha, alanz, austin, bgamari
Reviewed By: alanz
Subscribers: lelf, nomeata, gkaracha, thomie
Differential Revision: https://phabricator.haskell.org/D2669
GHC Trac Issues: #8779
>---------------------------------------------------------------
1a3f1eebf81952accb6340252816211c7d391300
compiler/basicTypes/ConLike.hs | 5 +
compiler/deSugar/Check.hs | 276 ++++++++++++++-------
compiler/deSugar/Desugar.hs | 14 +-
compiler/deSugar/DsMeta.hs | 1 +
compiler/deSugar/DsMonad.hs | 26 +-
compiler/deSugar/PmExpr.hs | 57 +++--
compiler/deSugar/TmOracle.hs | 13 +-
compiler/hsSyn/HsBinds.hs | 13 +
compiler/iface/IfaceSyn.hs | 10 +
compiler/iface/MkIface.hs | 20 +-
compiler/iface/TcIface.hs | 31 +++
compiler/main/HscTypes.hs | 42 +++-
compiler/main/TidyPgm.hs | 5 +-
compiler/parser/Lexer.x | 7 +-
compiler/parser/Parser.y | 13 +
compiler/parser/RdrHsSyn.hs | 2 +-
compiler/rename/RnBinds.hs | 10 +
compiler/typecheck/TcBinds.hs | 107 +++++++-
compiler/typecheck/TcRnDriver.hs | 2 +-
compiler/typecheck/TcRnMonad.hs | 3 +-
compiler/typecheck/TcRnTypes.hs | 24 +-
compiler/vectorise/Vectorise/Monad.hs | 2 +-
docs/users_guide/glasgow_exts.rst | 78 ++++++
.../tests/pmcheck/complete_sigs/Completesig03.hs | 7 +
.../pmcheck/complete_sigs/Completesig03.stderr | 2 +
.../tests/pmcheck/complete_sigs/Completesig03A.hs | 5 +
.../complete_sigs}/Makefile | 0
testsuite/tests/pmcheck/complete_sigs/all.T | 15 ++
.../tests/pmcheck/complete_sigs/completesig01.hs | 20 ++
.../tests/pmcheck/complete_sigs/completesig02.hs | 10 +
.../pmcheck/complete_sigs/completesig02.stderr | 4 +
.../tests/pmcheck/complete_sigs/completesig04.hs | 3 +
.../pmcheck/complete_sigs/completesig04.stderr | 4 +
.../tests/pmcheck/complete_sigs/completesig05.hs | 14 ++
.../tests/pmcheck/complete_sigs/completesig06.hs | 29 +++
.../pmcheck/complete_sigs/completesig06.stderr | 29 +++
.../tests/pmcheck/complete_sigs/completesig07.hs | 24 ++
.../pmcheck/complete_sigs/completesig07.stderr | 11 +
.../tests/pmcheck/complete_sigs/completesig08.hs | 30 +++
.../tests/pmcheck/complete_sigs/completesig09.hs | 13 +
.../tests/pmcheck/complete_sigs/completesig10.hs | 33 +++
.../pmcheck/complete_sigs/completesig10.stderr | 4 +
.../tests/pmcheck/complete_sigs/completesig11.hs | 14 ++
.../pmcheck/complete_sigs/completesig11.stderr | 4 +
.../tests/pmcheck/complete_sigs/completesig12.hs | 22 ++
.../tests/pmcheck/complete_sigs/completesig13.hs | 19 ++
.../tests/pmcheck/complete_sigs/completesig14.hs | 11 +
.../pmcheck/complete_sigs/completesig14.stderr | 4 +
.../tests/pmcheck/complete_sigs/completesig15.hs | 12 +
.../pmcheck/complete_sigs/completesig15.stderr | 4 +
testsuite/tests/pmcheck/should_compile/all.T | 2 +-
51 files changed, 956 insertions(+), 154 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 1a3f1eebf81952accb6340252816211c7d391300
More information about the ghc-commits
mailing list