[commit: ghc] master: Fix Template Haskell reification of unboxed tuple types (514c4a4)
git at git.haskell.org
git at git.haskell.org
Mon Jul 18 14:12:04 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/514c4a4741f3881672f1ccc1fe6d08a5d596bb87/ghc
>---------------------------------------------------------------
commit 514c4a4741f3881672f1ccc1fe6d08a5d596bb87
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Mon Jul 18 09:29:05 2016 -0400
Fix Template Haskell reification of unboxed tuple types
Summary:
Previously, Template Haskell reified unboxed tuple types as boxed
tuples with twice the appropriate arity.
Fixes #12403.
Test Plan: make test TEST=T12403
Reviewers: hvr, goldfire, austin, bgamari
Reviewed By: goldfire
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2405
GHC Trac Issues: #12403
>---------------------------------------------------------------
514c4a4741f3881672f1ccc1fe6d08a5d596bb87
compiler/typecheck/TcSplice.hs | 4 +++-
docs/users_guide/8.0.2-notes.rst | 6 ++++++
testsuite/tests/th/{T10697_decided_1.hs => T12403.hs} | 5 +++--
testsuite/tests/th/T12403.stdout | 1 +
testsuite/tests/th/all.T | 2 ++
5 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
index fa68d2e..6ae1ba4 100644
--- a/compiler/typecheck/TcSplice.hs
+++ b/compiler/typecheck/TcSplice.hs
@@ -1819,7 +1819,9 @@ reify_tc_app tc tys
tc_binders = tyConBinders tc
tc_res_kind = tyConResKind tc
- r_tc | isTupleTyCon tc = if isPromotedDataCon tc
+ r_tc | isUnboxedTupleTyCon tc = TH.UnboxedTupleT (arity `div` 2)
+ -- See Note [Unboxed tuple RuntimeRep vars] in TyCon
+ | isTupleTyCon tc = if isPromotedDataCon tc
then TH.PromotedTupleT arity
else TH.TupleT arity
| tc `hasKey` listTyConKey = TH.ListT
diff --git a/docs/users_guide/8.0.2-notes.rst b/docs/users_guide/8.0.2-notes.rst
index d5d442f..39ad028 100644
--- a/docs/users_guide/8.0.2-notes.rst
+++ b/docs/users_guide/8.0.2-notes.rst
@@ -32,6 +32,12 @@ Compiler
initial cmm from STG-to-C-- code generation and :ghc-flag:`-ddump-cmm-verbose`
to obtain the intermediates from all C-- pipeline stages.
+Template Haskell
+~~~~~~~~~~~~~~~~
+
+- Reifying types that contain unboxed tuples now works correctly. (Previously,
+ Template Haskell reified unboxed tuples as boxed tuples with twice their
+ appropriate arity.)
TODO FIXME Heading title
~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/testsuite/tests/th/T10697_decided_1.hs b/testsuite/tests/th/T12403.hs
similarity index 50%
copy from testsuite/tests/th/T10697_decided_1.hs
copy to testsuite/tests/th/T12403.hs
index 241cec3..d4aad62 100644
--- a/testsuite/tests/th/T10697_decided_1.hs
+++ b/testsuite/tests/th/T12403.hs
@@ -1,11 +1,12 @@
{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE UnboxedTuples #-}
module Main where
import Language.Haskell.TH
-data T = T {-# UNPACK #-} !Int !Int Int
+data T = T (# Int, Int #)
$(return [])
main :: IO ()
-main = putStrLn $(reifyConStrictness 'T >>= stringE . show)
+main = putStrLn $(reify ''T >>= stringE . pprint)
diff --git a/testsuite/tests/th/T12403.stdout b/testsuite/tests/th/T12403.stdout
new file mode 100644
index 0000000..9b75e8b
--- /dev/null
+++ b/testsuite/tests/th/T12403.stdout
@@ -0,0 +1 @@
+data Main.T = Main.T ((# , #) GHC.Types.Int GHC.Types.Int)
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index ff2d6d4..3f448d7 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -418,3 +418,5 @@ test('T11484', normal, compile, ['-v0'])
test('T8761', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T12130', extra_clean(['T12130a.hi','T12130a.o']),
multimod_compile, ['T12130', '-v0 ' + config.ghc_th_way_flags])
+test('T12403', omit_ways(['ghci']),
+ compile_and_run, ['-v0 -ddump-splices -dsuppress-uniques'])
More information about the ghc-commits
mailing list