| ... | @@ -142,12 +142,10 @@ pub fn print( | ... | @@ -142,12 +142,10 @@ pub fn print( |
| 142 | .extern_options_type => return writer.writeAll("std.builtin.ExternOptions"), | 142 | .extern_options_type => return writer.writeAll("std.builtin.ExternOptions"), |
| 143 | .type_info_type => return writer.writeAll("std.builtin.Type"), | 143 | .type_info_type => return writer.writeAll("std.builtin.Type"), |
| 144 | | 144 | |
| 145 | .empty_struct_value => return writer.writeAll(".{}"), | 145 | .empty_struct_value, .aggregate => { |
| 146 | .aggregate => { | | |
| 147 | if (level == 0) { | 146 | if (level == 0) { |
| 148 | return writer.writeAll(".{ ... }"); | 147 | return writer.writeAll(".{ ... }"); |
| 149 | } | 148 | } |
| 150 | const values = val.castTag(.aggregate).?; | | |
| 151 | if (ty.zigTypeTag() == .Struct) { | 149 | if (ty.zigTypeTag() == .Struct) { |
| 152 | try writer.writeAll(".{"); | 150 | try writer.writeAll(".{"); |
| 153 | const max_len = std.math.min(ty.structFieldCount(), max_aggregate_items); | 151 | const max_len = std.math.min(ty.structFieldCount(), max_aggregate_items); |
| ... | @@ -161,13 +159,7 @@ pub fn print( | ... | @@ -161,13 +159,7 @@ pub fn print( |
| 161 | } | 159 | } |
| 162 | try print(.{ | 160 | try print(.{ |
| 163 | .ty = ty.structFieldType(i), | 161 | .ty = ty.structFieldType(i), |
| 164 | .val = switch (ty.containerLayout()) { | 162 | .val = val.fieldValue(ty, i), |
| 165 | .Packed => values.data[i], | | |
| 166 | else => ty.structFieldValueComptime(i) orelse b: { | | |
| 167 | const vals = values.data; | | |
| 168 | break :b vals[i]; | | |
| 169 | }, | | |
| 170 | }, | | |
| 171 | }, writer, level - 1, mod); | 163 | }, writer, level - 1, mod); |
| 172 | } | 164 | } |
| 173 | if (ty.structFieldCount() > max_aggregate_items) { | 165 | if (ty.structFieldCount() > max_aggregate_items) { |
| ... | @@ -184,7 +176,7 @@ pub fn print( | ... | @@ -184,7 +176,7 @@ pub fn print( |
| 184 | | 176 | |
| 185 | var i: u32 = 0; | 177 | var i: u32 = 0; |
| 186 | while (i < max_len) : (i += 1) { | 178 | while (i < max_len) : (i += 1) { |
| 187 | buf[i] = std.math.cast(u8, values.data[i].toUnsignedInt(target)) orelse break :str; | 179 | buf[i] = std.math.cast(u8, val.fieldValue(ty, i).toUnsignedInt(target)) orelse break :str; |
| 188 | } | 180 | } |
| 189 | | 181 | |
| 190 | const truncated = if (len > max_string_len) " (truncated)" else ""; | 182 | const truncated = if (len > max_string_len) " (truncated)" else ""; |
| ... | @@ -199,7 +191,7 @@ pub fn print( | ... | @@ -199,7 +191,7 @@ pub fn print( |
| 199 | if (i != 0) try writer.writeAll(", "); | 191 | if (i != 0) try writer.writeAll(", "); |
| 200 | try print(.{ | 192 | try print(.{ |
| 201 | .ty = elem_ty, | 193 | .ty = elem_ty, |
| 202 | .val = values.data[i], | 194 | .val = val.fieldValue(ty, i), |
| 203 | }, writer, level - 1, mod); | 195 | }, writer, level - 1, mod); |
| 204 | } | 196 | } |
| 205 | if (len > max_aggregate_items) { | 197 | if (len > max_aggregate_items) { |