D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3009 - format.d(2072) uses deprecated function
Summary: format.d(2072) uses deprecated function
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-19 01:47 UTC by ZY Zhou
Modified: 2011-08-27 11:03 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ZY Zhou 2009-05-19 01:47:45 UTC
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 Andrei Alexandrescu 2009-08-27 21:51:07 UTC
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 Andrei Alexandrescu 2010-09-26 16:02:56 UTC
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 yebblies 2011-08-27 11:03:28 UTC
The first test case now compiles without error, and the second does too (once an import to std.array is added).