From c0e84b05923cef2d3fb1d6c0ef5b9e9a119363fe Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 18 May 2023 11:39:18 +0100 Subject: Fix #2536 --- src/types.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/types.cpp') 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 { -- cgit v1.2.3