Ensure identical types have same hash

This commit is contained in:
misomosi
2026-07-07 12:44:16 -04:00
parent d442fed12d
commit 723b8f563d

View File

@@ -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