diff options
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/types.cpp b/src/types.cpp index 889269564..70c4bcdbe 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -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 { |