zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 80bf5af3458b25ae7375b548dc7f42150fbef3c8 (tree)
parent 3e6dd0da7a9aae1e6e3d3e0d897a2b3a28bfc043
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Fri,  5 May 2023 18:34:52 -0700

fix AIR printing of interned constants

Diffstat:
Msrc/TypedValue.zig | 8++++++--
Msrc/print_air.zig | 2+-
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/TypedValue.zig b/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}); + } }, }; } diff --git a/src/print_air.zig b/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)}); }