diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-07-30 08:47:39 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-08-01 20:55:32 -0400 |
commit | e649085bb35628e10b08a9a1ef27095ad0510b40 (patch) | |
tree | 7d1f5492f4dd8fd35b068188e6d19f54e3955286 /testsuite | |
parent | 42c51e2f39ce829fa4a380b604c9a7f5ea71d28d (diff) | |
download | haskell-e649085bb35628e10b08a9a1ef27095ad0510b40.tar.gz |
Fix #15385 by using addDictsDs in matchGuards
When coverage checking pattern-matches, we rely on the call
sites in the desugarer to populate the local dictionaries and term
evidence in scope using `addDictsDs` and `addTmCsDs`. But it turns
out that only the call site for desugaring `case` expressions was
actually doing this properly. In another part of the desugarer,
`matchGuards` (which handles pattern guards), it did not update the
local dictionaries in scope at all, leading to #15385.
Fixing this is relatively straightforward: just augment the
`BindStmt` case of `matchGuards` to use `addDictsDs` and `addTmCsDs`.
Accomplishing this took a little bit of import/export tweaking:
* We now need to export `collectEvVarsPat` from `HsPat.hs`.
* To avoid an import cycle with `Check.hs`, I moved `isTrueLHsExpr`
from `DsGRHSs.hs` to `DsUtils.hs`, which resides lower on the
import chain.
Test Plan: make test TEST=T15385
Reviewers: simonpj, bgamari
Reviewed By: simonpj
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #15385
Differential Revision: https://phabricator.haskell.org/D4968
(cherry picked from commit 9d388eb83e797fd28e14868009c4786f3f1a8aa6)
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T15385.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/all.T | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T15385.hs b/testsuite/tests/pmcheck/should_compile/T15385.hs new file mode 100644 index 0000000000..dedf6c1553 --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T15385.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -Wincomplete-patterns #-} +module T15385 where + +import Data.Type.Equality + +data T a where + TInt :: T Int + TBool :: T Bool + +f1, f2 :: a :~: Int -> T a -> () +f1 eq t + | Refl <- eq + = case t of + TInt -> () +f2 eq t + = if | Refl <- eq + -> case t of + TInt -> () diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index a7b8bfb04c..4ee354ddb2 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -49,6 +49,8 @@ test('T14098', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T15450', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T15385', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, |