D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4638 - Regression: new writeln does not recognize "wstring toString"
Summary: Regression: new writeln does not recognize "wstring toString"
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: Shin Fujishiro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-12 20:38 UTC by Lionello Lunesu
Modified: 2010-11-16 13:06 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 Lionello Lunesu 2010-08-12 20:38:35 UTC
In 2.047, a struct could provide a toString that returned a wstring (as opposed to string) and it would get used when passing the struct to writeln. 

As of 2.048 a toString returning wstring is not detected and the struct's typename is returned instead. toString returning string works fine.

Repro:

import std.stdio;
import std.conv;

struct A
{
  wstring toString() { return "blah"; }
}

void main()
{
  A a;
  writeln(a);
  writeln(to!string(a));
  writeln(to!wstring(a));
}

DMD 2.047:
blah
blah
blah

DMD 2.048:
A
blah
blah
Comment 1 Shin Fujishiro 2010-11-16 13:06:54 UTC
Fixed: http://www.dsource.org/projects/phobos/changeset/2172