Commit 80bf5af345

Andrew Kelley <andrew@ziglang.org>
2023-05-06 03:34:52
fix AIR printing of interned constants
1 parent 3e6dd0d
Changed files (2)
src/print_air.zig
@@ -621,7 +621,7 @@ const Writer = struct {
     fn writeInterned(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
         const mod = w.module;
         const ip_index = w.air.instructions.items(.data)[inst].interned;
-        const ty = ip_index.toType();
+        const ty = mod.intern_pool.indexToKey(ip_index).typeOf().toType();
         try w.writeType(s, ty);
         try s.print(", {}", .{ip_index.toValue().fmtValue(ty, mod)});
     }
src/TypedValue.zig
@@ -413,8 +413,12 @@ pub fn print(
             .runtime_value => return writer.writeAll("[runtime value]"),
         },
         else => {
-            try writer.print("(interned: {})", .{val.ip_index});
-            return;
+            const key = mod.intern_pool.indexToKey(val.ip_index);
+            if (key.typeOf() == .type_type) {
+                return Type.print(val.toType(), writer, mod);
+            } else {
+                return writer.print("{}", .{val.ip_index});
+            }
         },
     };
 }