aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-05-13 16:08:50 +0100
committerGinger Bill <bill@gingerbill.org>2017-05-13 16:08:50 +0100
commit3e18f5f05782435c0410503a1d91e669d2bdffbf (patch)
tree0aa918da88a4f7f8c84573e4d27157f6a05715c3 /src
parentded99a2cabaf7bae461f22082268b544b20ba353 (diff)
Fix Ternary Operator IR bug
Diffstat (limited to 'src')
-rw-r--r--src/ir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ir.c b/src/ir.c
index 28b698b0d..b013c3227 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -3658,22 +3658,22 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) {
irValue *cond = ir_build_cond(proc, te->cond, then, else_);
ir_start_block(proc, then);
+ Type *type = type_of_expr(proc->module->info, expr);
+
ir_open_scope(proc);
- array_add(&edges, ir_build_expr(proc, te->x));
+ array_add(&edges, ir_emit_conv(proc, ir_build_expr(proc, te->x), type));
ir_close_scope(proc, irDeferExit_Default, NULL);
ir_emit_jump(proc, done);
ir_start_block(proc, else_);
ir_open_scope(proc);
- array_add(&edges, ir_build_expr(proc, te->y));
+ array_add(&edges, ir_emit_conv(proc, ir_build_expr(proc, te->y), type));
ir_close_scope(proc, irDeferExit_Default, NULL);
ir_emit_jump(proc, done);
ir_start_block(proc, done);
- Type *type = type_of_expr(proc->module->info, expr);
-
return ir_emit(proc, ir_instr_phi(proc, edges, type));
case_end;