From a109efd14ce0540fee30745125a4e2d65dc5ac1c Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 1 Aug 2022 11:22:58 +0200 Subject: [PATCH] Fix bug with ternary failables. --- src/compiler/llvm_codegen_expr.c | 5 +++-- src/version.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 099c74641..3a5fb3bc1 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -3752,12 +3752,13 @@ void gencontext_emit_ternary_expr(GenContext *c, BEValue *value, Expr *expr) llvm_value_set(value, rhs_value, rhs.type); return; } - LLVMValueRef phi = LLVMBuildPhi(c->builder, llvm_get_type(c, expr->type), "val"); + Type *expr_type = type_flatten(expr->type); + LLVMValueRef phi = LLVMBuildPhi(c->builder, llvm_get_type(c, expr_type), "val"); LLVMValueRef logic_values[2] = { lhs_value, rhs_value }; LLVMBasicBlockRef blocks[2] = { lhs_exit, rhs_exit }; LLVMAddIncoming(phi, logic_values, blocks, 2); - llvm_value_set(value, phi, expr->type); + llvm_value_set(value, phi, expr_type); } static LLVMValueRef llvm_emit_real(LLVMTypeRef type, Float f) { diff --git a/src/version.h b/src/version.h index 583f778d7..c84e960e6 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.3.0" \ No newline at end of file +#define COMPILER_VERSION "0.3.1" \ No newline at end of file