Bug 2899 – Object.toString is not declared const

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-04-25T14:33:00Z
Last change time
2015-06-09T01:26:27Z
Assigned to
bugzilla
Creator
someanon

Comments

Comment #0 by someanon — 2009-04-25T14:33:07Z
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?
Comment #1 by someanon — 2009-04-26T13:36:41Z
I changed line 2054 to: else w.put((cast(Object)obj).toString); it seems to be working.
Comment #2 by dfj1esp02 — 2009-05-27T06:24:24Z
*** This issue has been marked as a duplicate of issue 1824 ***