Bug 15061 – std.experimental.logger uses @safe on function templates
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-09-15T15:38:00Z
Last change time
2015-10-15T16:48:47Z
Assigned to
rburners
Creator
renezwanenburg
Comments
Comment #0 by renezwanenburg — 2015-09-15T15:38:52Z
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());