summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-05-17 10:34:09 +0100
committerBen Gamari <ben@smart-cactus.org>2021-08-04 13:03:39 -0400
commit066317d688ee09ebfe1e07aa52ff171cde223d15 (patch)
tree02719d270a562e03222be27b8dc322395e3b59fe
parent697db52044f577b584a04a8aac4cd211983fda61 (diff)
downloadhaskell-066317d688ee09ebfe1e07aa52ff171cde223d15.tar.gz
Make setBndrsDemandInfo work with only type variables
Fixes #19849 Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> (cherry picked from commit c4099b0908e3f4ae04312ca82af147eb1585cd09)
-rw-r--r--compiler/GHC/Core/Opt/DmdAnal.hs9
-rw-r--r--testsuite/tests/stranal/should_compile/T19849.hs7
-rw-r--r--testsuite/tests/stranal/should_compile/all.T2
3 files changed, 15 insertions, 3 deletions
diff --git a/compiler/GHC/Core/Opt/DmdAnal.hs b/compiler/GHC/Core/Opt/DmdAnal.hs
index 1cf34c2ff8..150185e3ee 100644
--- a/compiler/GHC/Core/Opt/DmdAnal.hs
+++ b/compiler/GHC/Core/Opt/DmdAnal.hs
@@ -1076,9 +1076,12 @@ dictionaries.
-}
setBndrsDemandInfo :: [Var] -> [Demand] -> [Var]
-setBndrsDemandInfo (b:bs) (d:ds)
- | isTyVar b = b : setBndrsDemandInfo bs (d:ds)
- | otherwise = setIdDemandInfo b d : setBndrsDemandInfo bs ds
+setBndrsDemandInfo (b:bs) ds
+ | isTyVar b = b : setBndrsDemandInfo bs ds
+setBndrsDemandInfo (b:bs) (d:ds) =
+ let !new_info = setIdDemandInfo b d
+ !vars = setBndrsDemandInfo bs ds
+ in new_info : vars
setBndrsDemandInfo [] ds = ASSERT( null ds ) []
setBndrsDemandInfo bs _ = pprPanic "setBndrsDemandInfo" (ppr bs)
diff --git a/testsuite/tests/stranal/should_compile/T19849.hs b/testsuite/tests/stranal/should_compile/T19849.hs
new file mode 100644
index 0000000000..9fa50ef001
--- /dev/null
+++ b/testsuite/tests/stranal/should_compile/T19849.hs
@@ -0,0 +1,7 @@
+module T19849 where
+
+data T where
+ C :: forall k. T
+
+f :: T -> ()
+f C = ()
diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T
index bb3fcd2952..59348d6f13 100644
--- a/testsuite/tests/stranal/should_compile/all.T
+++ b/testsuite/tests/stranal/should_compile/all.T
@@ -55,3 +55,5 @@ test('T13380b', [ grep_errmsg('bigDeadAction') ], compile, ['-dppr-cols=200 -dd
# We just want to find the worker of foo in there:
test('T18122', [ grep_errmsg(r'wfoo =') ], compile, ['-ddump-simpl'])
+
+test('T19849', normal, compile, [''])