From 176f250bdb9c6f55e340c397aa1b9514b5ca47bc Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 28 Sep 2023 10:06:40 +0800 Subject: [PATCH] core: Fix missing conversion to i1 for IfExp --- nac3core/src/codegen/expr.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index d4dce64c..28e35247 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -1281,11 +1281,12 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( .unwrap() .to_basic_value_enum(ctx, generator, values[0].custom.unwrap())? .into_int_value(); + let left = generator.bool_to_i1(ctx, left); let current = ctx.builder.get_insert_block().unwrap().get_parent().unwrap(); let a_bb = ctx.ctx.append_basic_block(current, "a"); let b_bb = ctx.ctx.append_basic_block(current, "b"); let cont_bb = ctx.ctx.append_basic_block(current, "cont"); - ctx.builder.build_conditional_branch(generator.bool_to_i1(ctx, left), a_bb, b_bb); + ctx.builder.build_conditional_branch(left, a_bb, b_bb); let (a, b) = match op { Boolop::Or => { ctx.builder.position_at_end(a_bb); @@ -1451,6 +1452,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( .unwrap() .to_basic_value_enum(ctx, generator, test.custom.unwrap())? .into_int_value(); + let test = generator.bool_to_i1(ctx, test); let body_ty = body.custom.unwrap(); let is_none = ctx.unifier.get_representative(body_ty) == ctx.primitives.none; let result = if !is_none {