Bug 3009 – format.d(2072) uses deprecated function
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2009-05-19T01:47:00Z
Last change time
2011-08-27T11:03:28Z
Assigned to
bugzilla
Creator
rinick
Comments
Comment #0 by rinick — 2009-05-19T01:47:45Z
testcase:
------------------------------
import std.stdio;
struct A(T)
{
T[] datas;
alias datas this;
}
void main()
{
A!uint a;
writeln(a);
}
------------------------------
compiler warning:
toString(uint[]) called from D:\dmd\dmd\windows\bin\..\..\src\phobos\std\format.d(2072) is deprecated. Instead you may want to import std.conv and use to!string(x) instead of toString(x).
Comment #1 by andrei — 2009-08-27T21:51:07Z
This is very odd. If I comment out toString, the example compiles and runs. There must be something odd going on in the compiler. Deferring to Walter.
Comment #2 by andrei — 2010-09-26T16:02:56Z
I'm reassigning this to Walter. It's a failure of alias this. Reduced test case:
import std.stdio;
struct A(T)
{
T[] datas;
alias datas this;
}
void main()
{
uint[] x;
x.popFront();
A!uint a;
writeln(a);
}
What should happen is that a.popFront() should forward to a.datas.popFront(), which in turn rewrites itself into popFront(a.datas).
Comment #3 by yebblies — 2011-08-27T11:03:28Z
The first test case now compiles without error, and the second does too (once an import to std.array is added).