summaryrefslogtreecommitdiff
path: root/compiler/deSugar/Match.hs
diff options
context:
space:
mode:
authorGeorge Karachalias <george.karachalias@gmail.com>2016-02-03 19:06:45 +0100
committerBen Gamari <ben@smart-cactus.org>2016-02-04 10:27:36 +0100
commit28f951edfe50ea5182065144340061ec326781f5 (patch)
tree0bb7ecd5b29518b0addca890ededb967f09273ca /compiler/deSugar/Match.hs
parentdb121b2ec4596b99fed9781ec2d055f29e0d5b20 (diff)
downloadhaskell-28f951edfe50ea5182065144340061ec326781f5.tar.gz
Overhaul the Overhauled Pattern Match Checker
Overhaul the Overhauled Pattern Match Checker * Changed the representation of Value Set Abstractions. Instead of using a prefix tree, we now use a list of Value Vector Abstractions. The set of constraints Delta for every Value Vector Abstraction is the oracle state so that we solve everything only once. * Instead of doing everything lazily, we prune at once (and in general everything is much stricter). Hence, an example written with pattern guards is checked in almost the same time as the equivalent with pattern matching. * Do not store the covered and the divergent sets at all. Since what we only need is a yes/no (does this clause cover anything? Does it force any thunk?) We just keep a boolean for each. * Removed flags `-Wtoo-many-guards` and `-ffull-guard-reasoning`. Replaced with `fmax-pmcheck-iterations=n`. Still debatable what should the default `n` be. * When a guard is for sure not going to contribute anything, we treat it as such: The oracle is not called and cases `CGuard`, `UGuard` and `DGuard` from the paper are not happening at all (the generation of a fresh variable, the unfolding of the pattern list etc.). his combined with the above seems to be enough to drop the memory increase for test T783 down to 18.7%. * Do not export function `dsPmWarn` (it is now called directly from within `checkSingle` and `checkMatches`). * Make `PmExprVar` hold a `Name` instead of an `Id`. The term oracle does not handle type information so using `Id` was a waste of time/space. * Added testcases T11195, T11303b (data families) and T11374 The patch addresses at least the following: Trac #11195, #11276, #11303, #11374, #11162 Test Plan: validate Reviewers: goldfire, bgamari, hvr, austin Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1795
Diffstat (limited to 'compiler/deSugar/Match.hs')
-rw-r--r--compiler/deSugar/Match.hs16
1 files changed, 2 insertions, 14 deletions
diff --git a/compiler/deSugar/Match.hs b/compiler/deSugar/Match.hs
index 0128488d62..be089e6788 100644
--- a/compiler/deSugar/Match.hs
+++ b/compiler/deSugar/Match.hs
@@ -694,21 +694,9 @@ matchWrapper ctxt mb_scr (MG { mg_alts = L _ matches
when (isAnyPmCheckEnabled dflags (DsMatchContext ctxt locn)) $ do
- -- Count the number of guards that can fail
- guards <- computeNoGuards matches
-
- let simplify = not (gopt Opt_FullGuardReasoning dflags)
- && (guards > maximum_failing_guards)
-
-- See Note [Type and Term Equality Propagation]
addTmCsDs (genCaseTmCs1 mb_scr new_vars) $
- dsPmWarn dflags (DsMatchContext ctxt locn) $
- checkMatches simplify new_vars matches
-
- when (not (gopt Opt_FullGuardReasoning dflags)
- && wopt Opt_WarnTooManyGuards dflags
- && guards > maximum_failing_guards)
- (warnManyGuards (DsMatchContext ctxt locn))
+ checkMatches dflags (DsMatchContext ctxt locn) new_vars matches
; result_expr <- handleWarnings $
matchEquations ctxt new_vars eqns_info rhs_ty
@@ -777,7 +765,7 @@ matchSinglePat (Var var) ctx pat ty match_result
; locn <- getSrcSpanDs
; let pat' = getMaybeStrictPat dflags pat
-- pattern match check warnings
- ; dsPmWarn dflags (DsMatchContext ctx locn) (checkSingle var pat')
+ ; checkSingle dflags (DsMatchContext ctx locn) var pat'
; match [var] ty
[EqnInfo { eqn_pats = [pat'], eqn_rhs = match_result }] }