mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix #2536
This commit is contained in:
+11
-1
@@ -2769,13 +2769,23 @@ gb_internal Type *default_type(Type *type) {
|
|||||||
return 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) {
|
gb_internal i64 union_variant_index(Type *u, Type *v) {
|
||||||
u = base_type(u);
|
u = base_type(u);
|
||||||
GB_ASSERT(u->kind == Type_Union);
|
GB_ASSERT(u->kind == Type_Union);
|
||||||
|
|
||||||
for_array(i, u->Union.variants) {
|
for_array(i, u->Union.variants) {
|
||||||
Type *vt = u->Union.variants[i];
|
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) {
|
if (u->Union.kind == UnionType_no_nil) {
|
||||||
return cast(i64)(i+0);
|
return cast(i64)(i+0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user