From 48565ca88a6b8a9f8b22add0c50d221a2a4a07e9 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Thu, 15 May 2008 11:53:32 +0000 Subject: [PATCH] Tuples cannot contain unboxed types This bug allowed, for example f = let x = ( 1#, 'x' ) in x which is ill-typed because you can't put an unboxed value in a tuple. Core Lint fails on this program. The patch makes the program be rejcted up-front. --- compiler/typecheck/TcExpr.lhs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/typecheck/TcExpr.lhs b/compiler/typecheck/TcExpr.lhs index b844a2a..32223a5 100644 --- a/compiler/typecheck/TcExpr.lhs +++ b/compiler/typecheck/TcExpr.lhs @@ -314,7 +314,9 @@ tcExpr in_expr@(ExplicitPArr _ exprs) res_ty -- maybe empty -- The scrutinee should have a rigid type if x,y do -- The general scheme is the same as in tcIdApp tcExpr (ExplicitTuple exprs boxity) res_ty - = do { tvs <- newBoxyTyVars [argTypeKind | e <- exprs] + = do { let kind = case boxity of { Boxed -> liftedTypeKind + ; Unboxed -> argTypeKind } + ; tvs <- newBoxyTyVars [kind | e <- exprs] ; let tup_tc = tupleTyCon boxity (length exprs) tup_res_ty = mkTyConApp tup_tc (mkTyVarTys tvs) ; checkWiredInTyCon tup_tc -- Ensure instances are available -- 1.7.10.4