summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-07-30 08:47:39 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2018-07-30 08:47:39 -0400
commit9d388eb83e797fd28e14868009c4786f3f1a8aa6 (patch)
tree6f0bcc4637c6b9cb565f093b43c88dede3e29acb /testsuite
parent11de4380c2f16f374c6e8fbacf8dce00376e7efb (diff)
downloadhaskell-9d388eb83e797fd28e14868009c4786f3f1a8aa6.tar.gz
Fix #15385 by using addDictsDs in matchGuards
Summary: 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
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/pmcheck/should_compile/T15385.hs21
-rw-r--r--testsuite/tests/pmcheck/should_compile/all.T10
2 files changed, 27 insertions, 4 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 e382e3fda4..4030b0609a 100644
--- a/testsuite/tests/pmcheck/should_compile/all.T
+++ b/testsuite/tests/pmcheck/should_compile/all.T
@@ -44,25 +44,27 @@ test('T11276', compiler_stats_num_field('bytes allocated',
test('T11303b', compiler_stats_num_field('bytes allocated',
[(wordsize(64), 54373936, 10)]
- # 2018-07-14: 54373936 INITIAL
+ # 2018-07-14: 54373936 INITIAL
), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns +RTS -M1G -RTS'])
-
+
test('T11374', compiler_stats_num_field('bytes allocated',
[(wordsize(64), 280144864, 10)]
# 2018-07-14: 280144864 INITIAL
), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns +RTS -M1G -RTS'])
-
+
test('T11195', compiler_stats_num_field('bytes allocated',
[(wordsize(64), 7852567480, 10)]
# 2018-07-14: 7852567480 INITIAL
), compile, ['-package ghc -fwarn-incomplete-patterns -fwarn-overlapping-patterns +RTS -M2G -RTS'])
-
+
test('T11984', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T14086', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T14098', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
+test('T15385', normal, compile,
+ ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
# Other tests
test('pmc001', [], compile,