This commit is contained in:
gingerBill
2023-05-18 11:39:18 +01:00
parent f2e590be7a
commit c0e84b0592

View File

@@ -2769,13 +2769,23 @@ gb_internal Type *default_type(Type *type) {
return type;
}
gb_internal bool union_variant_index_types_equal(Type *v, Type *vt) {
if (are_types_identical(v, vt)) {
return true;
}
if (is_type_proc(v) && is_type_proc(vt)) {
return are_types_identical(base_type(v), base_type(vt));
}
return false;
}
gb_internal i64 union_variant_index(Type *u, Type *v) {
u = base_type(u);
GB_ASSERT(u->kind == Type_Union);
for_array(i, u->Union.variants) {
Type *vt = u->Union.variants[i];
if (are_types_identical(v, vt)) {
if (union_variant_index_types_equal(v, vt)) {
if (u->Union.kind == UnionType_no_nil) {
return cast(i64)(i+0);
} else {