From ba377c043d72d1740361593b69efda94c81eac85 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 2 Jun 2011 17:50:37 -0700 Subject: [PATCH] Handle _|_ values properly in trans Generate an LLVMUndef value of the proper type for an argument of type _|_. Otherwise we get an LLVM assertion failure. --- src/comp/middle/trans.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 08ec30dec6b5..acabb0566175 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5121,8 +5121,6 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f, ret res(bcx, pair_v); } } - - fail; // sadly needed b/c the compiler doesn't know yet that unimpl fails } fn trans_arg_expr(&@block_ctxt cx, @@ -5168,8 +5166,15 @@ fn trans_arg_expr(&@block_ctxt cx, if (arg.mode != ty::mo_alias) { bcx = take_ty(bcx, val, e_ty).bcx; } - - if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) { + + if (ty::type_is_bot(cx.fcx.lcx.ccx.tcx, e_ty)) { + // For values of type _|_, we generate an + // "undef" value, as such a value should never + // be inspected. It's important for the value + // to have type lldestty0 (the callee's expected type). + val = llvm::LLVMGetUndef(lldestty0); + } + else if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) { auto lldestty = lldestty0; if (arg.mode == ty::mo_val) { // FIXME: we'd prefer to use &&, but rustboot doesn't like it