From 1e6848ab92ef4ccf5eb14f05151fe05c90a0d3cf Mon Sep 17 00:00:00 2001 From: ychenfo Date: Thu, 2 Dec 2021 01:02:42 +0800 Subject: [PATCH] nac3core: distinguish i64 and i32 in bool conversion --- nac3core/src/toplevel/composer.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 50c5344..137f187 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -414,7 +414,14 @@ impl TopLevelComposer { let arg = args[0].1; if ctx.unifier.unioned(arg_ty, boolean) { Some(arg) - } else if ctx.unifier.unioned(arg_ty, int32) || ctx.unifier.unioned(arg_ty, int64) { + } else if ctx.unifier.unioned(arg_ty, int32) { + Some(ctx.builder.build_int_compare( + IntPredicate::NE, + ctx.ctx.i32_type().const_zero(), + arg.into_int_value(), + "bool", + ).into()) + } else if ctx.unifier.unioned(arg_ty, int64) { Some(ctx.builder.build_int_compare( IntPredicate::NE, ctx.ctx.i64_type().const_zero(),