[commit: ghc] master: mkDataConRep: fix bug in strictness signature (#14290) (5935acd)
git at git.haskell.org
git at git.haskell.org
Thu Sep 28 17:44:09 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/5935acdb1302263011c2023d5e7f4ec496c972c0/ghc
>---------------------------------------------------------------
commit 5935acdb1302263011c2023d5e7f4ec496c972c0
Author: Simon Marlow <marlowsd at gmail.com>
Date: Thu Sep 28 13:08:45 2017 -0400
mkDataConRep: fix bug in strictness signature (#14290)
The strictness signature for a data con wrapper wasn't including any
dictionary arguments, which meant that bangs on the fields of a
constructor with an existential context would be moved to the wrong
fields. See T14290 for an example.
Test Plan:
* New test T14290
* validate
Reviewers: simonpj, niteria, austin, bgamari, erikd
Reviewed By: simonpj, bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #14290
Differential Revision: https://phabricator.haskell.org/D4040
>---------------------------------------------------------------
5935acdb1302263011c2023d5e7f4ec496c972c0
compiler/basicTypes/MkId.hs | 6 +++++-
testsuite/tests/stranal/should_run/T14290.hs | 17 +++++++++++++++++
testsuite/tests/stranal/should_run/all.T | 1 +
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs
index 03ab04a..87e40dd 100644
--- a/compiler/basicTypes/MkId.hs
+++ b/compiler/basicTypes/MkId.hs
@@ -530,7 +530,11 @@ mkDataConRep dflags fam_envs wrap_name mb_bangs data_con
wrap_sig = mkClosedStrictSig wrap_arg_dmds (dataConCPR data_con)
- wrap_arg_dmds = map mk_dmd arg_ibangs
+ wrap_arg_dmds =
+ replicate (length theta) topDmd ++ map mk_dmd arg_ibangs
+ -- Don't forget the dictionary arguments when building
+ -- the strictness signature (#14290).
+
mk_dmd str | isBanged str = evalDmd
| otherwise = topDmd
diff --git a/testsuite/tests/stranal/should_run/T14290.hs b/testsuite/tests/stranal/should_run/T14290.hs
new file mode 100644
index 0000000..7093239
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T14290.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE ExistentialQuantification #-}
+module Main (main) where
+
+main :: IO ()
+main = r `seq` return ()
+
+r :: Rec
+r = Rec{ a = error "xxx", b = 3, c = True }
+
+class C t
+instance C Bool
+
+data Rec = forall t. C t => Rec
+ { a :: ()
+ , b :: !Int
+ , c :: t
+ }
diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T
index 0764746..dada817 100644
--- a/testsuite/tests/stranal/should_run/all.T
+++ b/testsuite/tests/stranal/should_run/all.T
@@ -15,3 +15,4 @@ test('T11555a', normal, compile_and_run, [''])
test('T12368', exit_code(1), compile_and_run, [''])
test('T12368a', exit_code(1), compile_and_run, [''])
test('T13380', [expect_broken(13380), exit_code(1)], compile_and_run, [''])
+test('T14290', normal, compile_and_run, [''])
More information about the ghc-commits
mailing list