summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2022-12-03 00:06:42 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-13 22:18:39 -0500
commite9d74a3e47a4709502d7c1923b8611c22183b777 (patch)
tree129abc4eae27d5259db3757b120bd6c95cae4774 /testsuite
parentc30accc2f8a0585c76cb534beda04fba624bce1c (diff)
downloadhaskell-e9d74a3e47a4709502d7c1923b8611c22183b777.tar.gz
Respect -XStrict in the pattern-match checker (#21761)
We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/pmcheck/should_compile/T21761.hs19
-rw-r--r--testsuite/tests/pmcheck/should_compile/T21761.stderr24
-rw-r--r--testsuite/tests/pmcheck/should_compile/all.T1
3 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T21761.hs b/testsuite/tests/pmcheck/should_compile/T21761.hs
new file mode 100644
index 0000000000..9298366f39
--- /dev/null
+++ b/testsuite/tests/pmcheck/should_compile/T21761.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE Strict #-}
+
+module T21761 where
+
+data Void
+
+idV :: Void -> Void
+idV v = v
+
+idV' :: Void -> Void
+idV' v = case v of w -> w
+
+bangIdV :: Void -> Void
+bangIdV !v = v
+
+bangIdV' :: Void -> Void
+bangIdV' v = case v of !w -> w
diff --git a/testsuite/tests/pmcheck/should_compile/T21761.stderr b/testsuite/tests/pmcheck/should_compile/T21761.stderr
new file mode 100644
index 0000000000..bae05e270a
--- /dev/null
+++ b/testsuite/tests/pmcheck/should_compile/T21761.stderr
@@ -0,0 +1,24 @@
+
+T21761.hs:10:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘idV’: idV v = ...
+
+T21761.hs:13:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘idV'’: idV' v = ...
+
+T21761.hs:13:20: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In a case alternative: w -> ...
+
+T21761.hs:16:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘bangIdV’: bangIdV !v = ...
+
+T21761.hs:19:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘bangIdV'’: bangIdV' v = ...
+
+T21761.hs:19:24: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In a case alternative: !w -> ...
diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T
index 6415e83dab..0980dbb157 100644
--- a/testsuite/tests/pmcheck/should_compile/all.T
+++ b/testsuite/tests/pmcheck/should_compile/all.T
@@ -157,3 +157,4 @@ test('EmptyCase008', [], compile, [overlapping_incomplete])
test('EmptyCase009', [], compile, [overlapping_incomplete])
test('EmptyCase010', [], compile, [overlapping_incomplete])
test('T19271', [], compile, [overlapping_incomplete])
+test('T21761', [], compile, [overlapping_incomplete])