aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-03-22 20:56:46 +0000
committergingerBill <bill@gingerbill.org>2020-03-22 20:56:46 +0000
commitdfc63dcb606146dcb7a4c1076e593c7991a84c9a (patch)
treefb1dee7ca1169c9b2aebca66d5ba87c213f99612 /src/ir.cpp
parent8dba0e332c73a08301c5ac6c0d310c483c66cb11 (diff)
Fix `for in` for pointer to map expressions
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 7779b02b3..540bd0406 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3967,6 +3967,10 @@ irValue *ir_map_entries(irProcedure *proc, irValue *value) {
irValue *ir_map_entries_ptr(irProcedure *proc, irValue *value) {
gbAllocator a = ir_allocator();
Type *t = base_type(type_deref(ir_type(value)));
+ if (is_type_pointer(t)) {
+ value = ir_emit_load(proc, value);
+ t = base_type(type_deref(t));
+ }
GB_ASSERT_MSG(t->kind == Type_Map, "%s", type_to_string(t));
init_map_internal_types(t);
Type *gst = t->Map.generated_struct_type;
@@ -10020,7 +10024,7 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) {
gbAllocator a = ir_allocator();
irAddr addr = ir_build_addr(proc, expr);
irValue *map = ir_addr_get_ptr(proc, addr);
- if (is_type_pointer(type_deref(ir_addr_type(addr)))) {
+ if (is_type_pointer(ir_addr_type(addr))) {
map = ir_addr_load(proc, addr);
}
irValue *entries_ptr = ir_map_entries_ptr(proc, map);