aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <jeroen@paramythic.com>2019-02-26 13:51:56 +0100
committerJeroen van Rijn <jeroen@paramythic.com>2019-02-26 13:51:56 +0100
commit6faab8e47a09a480880399ea63e716ba51428d9e (patch)
tree1b9923d4490cfdf350a60b7f6ff956a16032eed6 /src/ir.cpp
parenta0c81c79add95ce7a96b0d943545aa8b6bd71713 (diff)
Fix #345: panic when using enum as map key
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index eba159472..d52b4beaf 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3215,6 +3215,9 @@ irValue *ir_gen_map_key(irProcedure *proc, irValue *key, Type *key_type) {
key = ir_emit_conv(proc, key, key_type);
if (is_type_integer(t)) {
ir_emit_store(proc, ir_emit_struct_ep(proc, v, 0), ir_emit_conv(proc, key, hash_type));
+ } else if (is_type_enum(t)) {
+ irValue *e = ir_emit_bitcast(proc, key, t_uint);
+ ir_emit_store(proc, ir_emit_struct_ep(proc, v, 0), ir_emit_conv(proc, e, hash_type));
} else if (is_type_typeid(t)) {
irValue *i = ir_emit_bitcast(proc, key, t_uint);
ir_emit_store(proc, ir_emit_struct_ep(proc, v, 0), ir_emit_conv(proc, i, hash_type));