summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2020-02-03 14:41:23 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-10 20:04:09 -0500
commitf3e737bbcae7290856450ff9c8b0c7e31fca0c10 (patch)
tree8767c43c867ae671e17c2a93eddf9242c0523060 /testsuite
parent00dc0f7e66a18ab50931325cb6333a2bfd2a6650 (diff)
downloadhaskell-f3e737bbcae7290856450ff9c8b0c7e31fca0c10.tar.gz
Fix long distance info for record updates
For record updates where the `record_expr` is a variable, as in #17783: ```hs data PartialRec = No | Yes { a :: Int, b :: Bool } update No = No update r@(Yes {}) = r { b = False } ``` We should make use of long distance info in `-Wincomplete-record-updates` checking. But the call to `matchWrapper` in the `RecUpd` case didn't specify a scrutinee expression, which would correspond to the `record_expr` `r` here. That is fixed now. Fixes #17783.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/pmcheck/should_compile/T17783.hs9
-rw-r--r--testsuite/tests/pmcheck/should_compile/all.T2
2 files changed, 11 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T17783.hs b/testsuite/tests/pmcheck/should_compile/T17783.hs
new file mode 100644
index 0000000000..8ac9246000
--- /dev/null
+++ b/testsuite/tests/pmcheck/should_compile/T17783.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -Wincomplete-record-updates #-}
+
+module Bug where
+
+data PartialRec = No
+ | Yes { a :: Int, b :: Bool }
+
+update No = No
+update r@(Yes {}) = r { b = False }
diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T
index 9d37f36fe5..dcb9ca4081 100644
--- a/testsuite/tests/pmcheck/should_compile/all.T
+++ b/testsuite/tests/pmcheck/should_compile/all.T
@@ -112,6 +112,8 @@ test('T17646', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T17703', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
+test('T17783', normal, compile,
+ ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
# Other tests
test('pmc001', [], compile,