D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7317 - writeln cannot handle alias this of array type
Summary: writeln cannot handle alias this of array type
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-19 00:52 UTC by timon.gehr
Modified: 2012-04-19 17:24 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-01-19 00:52:31 UTC
class C{
    Object[] x;
    alias x this;
    string toString(){return "foo";}
}
void main(){writeln(new C);} // prints "[]"
Comment 1 SomeDude 2012-04-19 14:28:45 UTC
Works on 2.059

PS E:\DigitalMars\dmd2\samples> rdmd bug.d
foo
Comment 2 Kenji Hara 2012-04-19 17:24:24 UTC
In 2.059, std.format module treats alias this type as proper super type.
In this case, class C has explicit toString member function, so it is used.

Pull request I had posted:
https://github.com/D-Programming-Language/phobos/pull/488

Phobos commit:
https://github.com/D-Programming-Language/phobos/commit/b90e2835eb6ca63fe58789d6f38e414f5bda70ed