Added formatting of function pointers (#1843)
This commit is contained in:
parent
45e72c0b39
commit
a7670e80a4
@ -243,6 +243,9 @@ pub fn formatType(
|
||||
}
|
||||
return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(&value));
|
||||
},
|
||||
builtin.TypeId.Fn => {
|
||||
return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value));
|
||||
},
|
||||
else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
|
||||
}
|
||||
}
|
||||
@ -1013,6 +1016,10 @@ test "fmt.format" {
|
||||
const value = @intToPtr(fn () void, 0xdeadbeef);
|
||||
try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
|
||||
}
|
||||
{
|
||||
const value = @intToPtr(fn () void, 0xdeadbeef);
|
||||
try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
|
||||
}
|
||||
try testFmt("buf: Test \n", "buf: {s5}\n", "Test");
|
||||
try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", "Test");
|
||||
try testFmt("cstr: Test C\n", "cstr: {s}\n", c"Test C");
|
||||
|
Loading…
x
Reference in New Issue
Block a user