aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-05-03 13:38:15 +0100
committergingerBill <bill@gingerbill.org>2021-05-03 13:38:15 +0100
commit1a3784c4df312df72f15b179e083d83818e08def (patch)
tree18c210412f8591caac88f5dbe0b00653490faec2 /src/check_type.cpp
parent518ecaf9c909bf2fd372fd758a5075f603b07d75 (diff)
Allow unions which are comparable to also be valid map keys (i.e. hashable)
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index aef1ddc7a..f70230682 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -2109,6 +2109,12 @@ void add_map_key_type_dependencies(CheckerContext *ctx, Type *key) {
Entity *field = key->Struct.fields[i];
add_map_key_type_dependencies(ctx, field->type);
}
+ } else if (key->kind == Type_Union) {
+ add_package_dependency(ctx, "runtime", "default_hasher_n");
+ for_array(i, key->Union.variants) {
+ Type *v = key->Union.variants[i];
+ add_map_key_type_dependencies(ctx, v);
+ }
} else if (key->kind == Type_EnumeratedArray) {
add_package_dependency(ctx, "runtime", "default_hasher_n");
add_map_key_type_dependencies(ctx, key->EnumeratedArray.elem);