Commit 514c4a47 authored by Ryan Scott's avatar Ryan Scott

Fix Template Haskell reification of unboxed tuple types

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:

GHC Trac Issues: #12403
parent 3fa3fe8a
......@@ -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
......@@ -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
{-# 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)
data Main.T = Main.T ((# , #) GHC.Types.Int GHC.Types.Int)
......@@ -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'])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment