From 8f2a97a562916a882ec0818e6295d41971aad5f1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 27 Mar 2011 20:20:12 -0400 Subject: Add partial support for if expressions resulting in generic types --- src/comp/middle/trans.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/comp') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 433a8012..3995e1de 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3046,11 +3046,14 @@ fn trans_if(@block_ctxt cx, @ast.expr cond, // If we have an else expression, then the entire // if expression can have a non-nil type. - // FIXME: Handle dynamic type sizes auto expr_ty = ty.expr_ty(elexpr); - expr_llty = type_of(else_res.bcx.fcx.ccx, expr_ty); - if (ty.type_is_structural(expr_ty)) { - expr_llty = T_ptr(expr_llty); + if (ty.type_has_dynamic_size(expr_ty)) { + expr_llty = T_typaram_ptr(cx.fcx.ccx.tn); + } else { + expr_llty = type_of(else_res.bcx.fcx.ccx, expr_ty); + if (ty.type_is_structural(expr_ty)) { + expr_llty = T_ptr(expr_llty); + } } } case (_) { -- cgit v1.2.3