Skip to content

Commit 98ed49d

Browse files
odin-lang#4873 issue fixed
1 parent d234538 commit 98ed49d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/llvm_backend_expr.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -3110,6 +3110,17 @@ gb_internal lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind,
31103110
}
31113111
}
31123112
break;
3113+
case Type_Array: {
3114+
// For arrays where the element type is nil-comparable (like string),
3115+
// perform a memory comparison of the entire array.
3116+
auto args = array_make<lbValue>(permanent_allocator(), 2);
3117+
lbValue lhs = lb_address_from_load_or_generate_local(p, x);
3118+
args[0] = lb_emit_conv(p, lhs, t_rawptr);
3119+
args[1] = lb_const_int(p->module, t_int, type_size_of(x.type));
3120+
lbValue mem_cmp = lb_emit_runtime_call(p, "memory_compare_zero", args);
3121+
return lb_emit_comp(p, op_kind, mem_cmp, lb_const_int(p->module, t_int, 0));
3122+
} break;
3123+
31133124

31143125
case Type_DynamicArray:
31153126
{

0 commit comments

Comments
 (0)