Thread overview
[Issue 2899] New: Object.toString is not declared const
Apr 25, 2009
d-bugmail
Apr 26, 2009
d-bugmail
May 27, 2009
Sobirari Muhomori
April 25, 2009
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?


-- 

April 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2899





------- Comment #1 from someanon@yahoo.com  2009-04-26 13:36 -------
I changed line 2054 to:

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

it seems to be working.


-- 

May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2899


Sobirari Muhomori <maxmo@pochta.ru> changed:

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




--- Comment #2 from Sobirari Muhomori <maxmo@pochta.ru>  2009-05-27 06:24:24 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: -------