www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2899] New: Object.toString is not declared const

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2899

           Summary: Object.toString is not declared const
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: someanon yahoo.com


I don't have a code snippets, but in dmd-v2.029/src/phobos/std/format.d:2054

    else static if (is(const(D) : const Object)) {
        //    BUG 2367   
        //if (obj is null) w.write("null");
        if (obj is null) w.put("null"[]);
        else w.put(obj.toString);  // 2054
    }

dmd/linux/bin/../bin/../../src/phobos/std/format.d(2054): Error: obj.toString
can only be called on a mutable object, not const(...)

This because Object.toString is not declared const.

So how to fix this?


-- 
Apr 25 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2899






I changed line 2054 to:

    else w.put((cast(Object)obj).toString);

it seems to be working.


-- 
Apr 26 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2899


Sobirari Muhomori <maxmo pochta.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE





PDT ---


*** This issue has been marked as a duplicate of issue 1824 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27 2009