From 0d92ef3513ba52d4d7b1b15eb54cbaecd55b81bd Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Mon, 17 May 2021 10:34:09 +0100 Subject: Make setBndrsDemandInfo work with only type variables Fixes #19849 Co-authored-by: Krzysztof Gogolewski (cherry picked from commit c4099b0908e3f4ae04312ca82af147eb1585cd09) (cherry picked from commit 066317d688ee09ebfe1e07aa52ff171cde223d15) --- compiler/GHC/Core/Opt/DmdAnal.hs | 9 ++++++--- testsuite/tests/stranal/should_compile/T19849.hs | 7 +++++++ testsuite/tests/stranal/should_compile/all.T | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 testsuite/tests/stranal/should_compile/T19849.hs 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, ['']) -- cgit v1.2.1