From d6fc13f08d449f1edf1ae4a624db0a359be18311 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 10 Jan 2017 10:32:56 -0800 Subject: [PATCH] Fix a couple of problems --- src/compilation.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compilation.rs b/src/compilation.rs index a22facd..99a9ba0 100644 --- a/src/compilation.rs +++ b/src/compilation.rs @@ -168,7 +168,7 @@ impl CodeGen for Expression { zero, "is_nonzero"); - let func = 4; + let func: LLVMValueRef = zero; let then_block = LLVMWrap::AppendBasicBlockInContext(data.context, func, "entry"); let else_block = @@ -179,7 +179,10 @@ impl CodeGen for Expression { LLVMWrap::PositionBuilderAtEnd(data.builder, then_block); let then_return = then_expr.codegen(data); LLVMWrap::BuildBr(data.builder, merge_block); - let else_return = else_expr.codegen(data); + let else_return = match else_expr { + &Some(e) => e.codegen(data), + &None => zero, + }; LLVMWrap::BuildBr(data.builder, merge_block); LLVMWrap::PositionBuilderAtEnd(data.builder, else_block); zero