fix AIR printing of interned constants

This commit is contained in:
Andrew Kelley 2023-05-05 18:34:52 -07:00
parent 3e6dd0da7a
commit 80bf5af345
2 changed files with 7 additions and 3 deletions

View File

@ -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});
}
},
};
}

View File

@ -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)});
}