mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Allow comparisons between empty struct{} and union{}
This commit is contained in:
@@ -2210,6 +2210,15 @@ gb_internal lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValu
|
|||||||
lbValue left_ptr = lb_address_from_load_or_generate_local(p, left);
|
lbValue left_ptr = lb_address_from_load_or_generate_local(p, left);
|
||||||
lbValue right_ptr = lb_address_from_load_or_generate_local(p, right);
|
lbValue right_ptr = lb_address_from_load_or_generate_local(p, right);
|
||||||
lbValue res = {};
|
lbValue res = {};
|
||||||
|
if (type_size_of(type) == 0) {
|
||||||
|
switch (op_kind) {
|
||||||
|
case Token_CmpEq:
|
||||||
|
return lb_const_bool(p->module, t_bool, true);
|
||||||
|
case Token_NotEq:
|
||||||
|
return lb_const_bool(p->module, t_bool, false);
|
||||||
|
}
|
||||||
|
GB_PANIC("invalid operator");
|
||||||
|
}
|
||||||
if (is_type_simple_compare(type)) {
|
if (is_type_simple_compare(type)) {
|
||||||
// TODO(bill): Test to see if this is actually faster!!!!
|
// TODO(bill): Test to see if this is actually faster!!!!
|
||||||
auto args = array_make<lbValue>(permanent_allocator(), 3);
|
auto args = array_make<lbValue>(permanent_allocator(), 3);
|
||||||
|
|||||||
@@ -2313,9 +2313,6 @@ gb_internal bool is_type_comparable(Type *t) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Type_Struct:
|
case Type_Struct:
|
||||||
if (type_size_of(t) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (t->Struct.soa_kind != StructSoa_None) {
|
if (t->Struct.soa_kind != StructSoa_None) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2331,9 +2328,6 @@ gb_internal bool is_type_comparable(Type *t) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Type_Union:
|
case Type_Union:
|
||||||
if (type_size_of(t) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for_array(i, t->Union.variants) {
|
for_array(i, t->Union.variants) {
|
||||||
Type *v = t->Union.variants[i];
|
Type *v = t->Union.variants[i];
|
||||||
if (!is_type_comparable(v)) {
|
if (!is_type_comparable(v)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user