From b1f714336b35c5c3d645fb5a5aa3cd3c5ea6e78e Mon Sep 17 00:00:00 2001 From: NoxMentis Date: Tue, 10 Feb 2026 23:18:33 +0100 Subject: [PATCH] Fixed an issue when parsing an expression with a cast to a signed 64bit integer would truncate all 64 bits. Also fixes an issue where a cast from a 64bit float to a 32bit signed integer would skip the conversion and instead truncate the top 32bits. --- src/eval/eval_ir.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index 0293a03db..c53eb0653 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -890,11 +890,10 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I { new_tree = e_irtree_convert_lo(arena, in_tree, out_group, in_group); } - if(cast_type_byte_size < casted_type_byte_size && e_type_kind_is_integer(cast_type_unwrapped_kind)) - { - new_tree = e_irtree_trunc(arena, in_tree, cast_type); - } - if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind)) + else if(cast_type_byte_size < casted_type_byte_size && ( + e_type_kind_is_integer(cast_type_unwrapped_kind) || + ( e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind)) + )) { new_tree = e_irtree_trunc(arena, in_tree, cast_type); } @@ -1518,11 +1517,10 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I { new_tree = e_irtree_convert_lo(arena, in_tree, out_group, in_group); } - if(cast_type_byte_size < casted_type_byte_size && e_type_kind_is_integer(cast_type_unwrapped_kind)) - { - new_tree = e_irtree_trunc(arena, in_tree, cast_type); - } - if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind)) + else if(cast_type_byte_size < casted_type_byte_size && ( + e_type_kind_is_integer(cast_type_unwrapped_kind) || + ( e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind)) + )) { new_tree = e_irtree_trunc(arena, in_tree, cast_type); }