mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-17 12:02:40 +00:00
Fix #5129
This commit is contained in:
@@ -3375,7 +3375,7 @@ gb_internal bool union_variant_index_types_equal(Type *v, Type *vt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gb_internal i64 union_variant_index(Type *u, Type *v) {
|
||||
gb_internal i64 union_variant_index_checked(Type *u, Type *v) {
|
||||
u = base_type(u);
|
||||
GB_ASSERT(u->kind == Type_Union);
|
||||
|
||||
@@ -3389,9 +3389,24 @@ gb_internal i64 union_variant_index(Type *u, Type *v) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
GB_PANIC("unfound variant -> %s %s", type_to_string(u), type_to_string(v));
|
||||
return -1;
|
||||
}
|
||||
|
||||
gb_internal bool union_is_variant_of(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 (union_variant_index_types_equal(v, vt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
gb_internal i64 union_tag_size(Type *u) {
|
||||
u = base_type(u);
|
||||
GB_ASSERT(u->kind == Type_Union);
|
||||
|
||||
Reference in New Issue
Block a user