Browse Source

Fix key lookup of pointer to map

gingerBill 7 years ago
parent
commit
976415ff9d
3 changed files with 6 additions and 2 deletions
  1. 1 1
      core/fmt.odin
  2. 1 1
      src/check_stmt.cpp
  3. 4 0
      src/ir.cpp

+ 1 - 1
core/fmt.odin

@@ -939,7 +939,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
 		}
 
 		if data == nil || tag <= 0 {
-			write_string(fi.buf, "(union)");
+			write_string(fi.buf, "nil");
 		} else {
 			ti := info.variants[tag-1];
 			fmt_arg(fi, any{data, ti}, verb);

+ 1 - 1
src/check_stmt.cpp

@@ -1281,7 +1281,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 
 					if (!is_type_ordered(x.type)) {
 						gbString str = type_to_string(x.type);
-						error(x.expr, "Unordered type '%s', is invalid for an interval expression", str);
+						error(expr, "Unordered type '%s', is invalid for an interval expression", str);
 						gb_string_free(str);
 						continue;
 					}

+ 4 - 0
src/ir.cpp

@@ -5531,6 +5531,10 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
 
 		if (is_type_map(t)) {
 			irValue *map_val = ir_build_addr_ptr(proc, ie->expr);
+			if (deref) {
+				map_val = ir_emit_load(proc, map_val);
+			}
+
 			irValue *key = ir_build_expr(proc, ie->index);
 			key = ir_emit_conv(proc, key, t->Map.key);