www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15061] New: std.experimental.logger uses safe on function


          Issue ID: 15061
           Summary: std.experimental.logger uses  safe on function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: renezwanenburg 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
"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);
tracef("%s", s.toString());

Sep 15 2015