https://issues.dlang.org/show_bug.cgi?id=15061
Issue ID: 15061
Summary: std.experimental.logger uses @safe on function
templates
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: [email protected]
Reporter: [email protected]
This means I can't log structs with a custom toString(). For example,
import std.experimental.logger;
struct S
{
string toString()
{
return "";
}
}
void main()
{
S s;
tracef("%s", s);
}
Results in
Error: safe function
'std.experimental.logger.core.Logger.memLogFunctions!cast(LogLevel)cast(ubyte)32u.logImplf!(15,
"test.d", "test.main", "void test.main()", "test", S).logImplf' cannot call
system function 'std.format.formattedWrite!(MsgRange, char, S).formattedWrite'
A workaround is to change
tracef("%s", s);
into
tracef("%s", s.toString());
--