D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7598 - format() doesn't work with alias this
Summary: format() doesn't work with alias this
Status: RESOLVED DUPLICATE of issue 6595
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-02-26 18:23 UTC by Andrej Mitrovic
Modified: 2012-04-24 04:59 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 Andrej Mitrovic 2012-02-26 18:23:19 UTC
import std.stdio;
import std.string;

struct Wrap
{
    string a;
    alias a this;
}

struct Foo
{
    Wrap wrap;
    string toString() { return format("%s", wrap); }
}

void main()
{
    Foo foo;
    writeln(foo);
}

std.format.FormatException@std\format.d(4400): Can't convert test.Wrap to string: "string toString()" not defined
Comment 1 SomeDude 2012-04-20 02:18:41 UTC
See also issue 7922
Comment 2 Kenji Hara 2012-04-20 02:30:27 UTC
(In reply to comment #1)
> See also issue 7922

No, this is std.string.format function problem, then it is Phobos issue.
And 7922 is a dmd issue. So they are not related.
Comment 3 Kenji Hara 2012-04-24 04:59:22 UTC

*** This issue has been marked as a duplicate of issue 6595 ***