[Issue 15061] New: std.experimental.logger uses @safe on function templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Sep 15 08:38:52 PDT 2015


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: nobody at puremagic.com
          Reporter: renezwanenburg at gmail.com

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());

--


More information about the Digitalmars-d-bugs mailing list