From 723b8f563d05136074a996f5d76d6a5880e57193 Mon Sep 17 00:00:00 2001 From: misomosi Date: Tue, 7 Jul 2026 12:44:16 -0400 Subject: [PATCH] Ensure identical types have same hash --- src/name_canonicalization.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/name_canonicalization.cpp b/src/name_canonicalization.cpp index 7cabdb834..13fa01830 100644 --- a/src/name_canonicalization.cpp +++ b/src/name_canonicalization.cpp @@ -516,9 +516,17 @@ gb_internal u64 type_hash_canonical_type(Type *type) { return prev_hash; } + // NOTE(tf2spi): Unwrap type aliases similar to are_types_identical* + Type *type_unaliased = type; + if (type->kind == Type_Named) { + Entity *e = type->Named.type_name; + if (e->TypeName.is_type_alias) { + type_unaliased = type->Named.base; + } + } TypeWriter w = {}; type_writer_make_hasher(&w, &w.hash_ctx); - write_type_to_canonical_string(&w, type); + write_type_to_canonical_string(&w, type_unaliased); u64 hash = typeid_hash_context_fini(&w.hash_ctx); if (build_context.webkit_switch_workaround) { // Clear the top bit so every `typeid` is in [1, 2^63). A `switch` over a