diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-07-18 09:29:05 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-07-18 09:31:20 -0400 |
commit | 514c4a4741f3881672f1ccc1fe6d08a5d596bb87 (patch) | |
tree | 8cb1c47c8a7a50370a1979fa913810c76d4c9471 | |
parent | 3fa3fe8a9a8afa67829e12efa5d25b76e58a185a (diff) | |
download | haskell-514c4a4741f3881672f1ccc1fe6d08a5d596bb87.tar.gz |
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
-rw-r--r-- | compiler/typecheck/TcSplice.hs | 4 | ||||
-rw-r--r-- | docs/users_guide/8.0.2-notes.rst | 6 | ||||
-rw-r--r-- | testsuite/tests/th/T12403.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/th/T12403.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 2 |
5 files changed, 24 insertions, 1 deletions
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs index fa68d2e98b..6ae1ba4341 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 d5d442f59b..39ad0284ad 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/T12403.hs b/testsuite/tests/th/T12403.hs new file mode 100644 index 0000000000..d4aad62cab --- /dev/null +++ b/testsuite/tests/th/T12403.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE UnboxedTuples #-} +module Main where + +import Language.Haskell.TH + +data T = T (# Int, Int #) + +$(return []) + +main :: IO () +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 0000000000..9b75e8b272 --- /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 ff2d6d465f..3f448d70a8 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']) |