authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-13 20:02:15+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-13 23:21:23-05:00
loga471a57560401c5562c4dc3e588227b689bf9487
treed7761cc097c7bd0791ac025392b6a45a27567dee
parent343249efd845c30fbdcb18a37ebb356ab19da742

std: Fix formatting of type values

Closes #7429

1 files changed, 7 insertions(+), 1 deletions(-)

lib/std/fmt.zig+7-1
......@@ -537,7 +537,7 @@ pub fn formatType(
537537 .Fn => {
538538 return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) });
539539 },
540 .Type => return writer.writeAll(@typeName(T)),
540 .Type => return formatBuf(@typeName(value), options, writer),
541541 .EnumLiteral => {
542542 const buffer = [_]u8{'.'} ++ @tagName(value);
543543 return formatType(buffer, fmt, options, writer, max_depth);
......@@ -2052,6 +2052,12 @@ test "null" {
20522052 try testFmt("null", "{}", .{inst});
20532053}
20542054
2055test "type" {
2056 try testFmt("u8", "{}", .{u8});
2057 try testFmt("?f32", "{}", .{?f32});
2058 try testFmt("[]const u8", "{}", .{[]const u8});
2059}
2060
20552061test "named arguments" {
20562062 try testFmt("hello world!", "{} world{c}", .{ "hello", '!' });
20572063 try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" });