D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7628 - Regression with std.string format and alias this
Summary: Regression with std.string format and alias this
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-03-02 06:05 UTC by David
Modified: 2012-03-08 22:54 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 David 2012-03-02 06:05:48 UTC
This code runs on ideone: http://ideone.com/iSBBO 
But not here, 32 bit, Linux, dmd 2.058 with:


/usr/include/d/std/conv.d(101): Error: template std.format.formatValue(Writer,T,Char) if (is(Unqual!(T) == bool)) formatValue(Writer,T,Char) if (is(Unqual!(T) == bool)) matches more than one template declaration, /usr/include/d/std/format.d(1342):formatValue(Writer,T,Char) if (!isSomeString!(T) && isDynamicArray!(T)) and /usr/include/d/std/format.d(1978):formatValue(Writer,T,Char) if (!isSomeString!(T) && (is(T == struct) || is(T == union)))
Comment 1 bioinfornatics 2012-03-02 06:07:50 UTC
I got same error as you on linux 64 with ldc2 and dmdfe 2.058
Comment 2 Kenji Hara 2012-03-02 06:22:09 UTC
Don't link to an external site, because it may be disappear in the future.
Instead write code directly, or attach the testcase, please.

> http://ideone.com/iSBBO 

import std.string;
import std.stdio;

struct S {
    ubyte[] metadata;

    string toString(){
        return "%s".format( metadata );
    }
}

struct Foo {
    S[] bar;
    alias bar this;

    string toString(){
        return "%s".format( bar );
    }
}

void main(){
    S   s;
    s.metadata = [0,1,2];
    Foo foo;
    foo.bar = [s];

    writeln( foo );
}
Comment 4 Kenji Hara 2012-03-03 08:29:31 UTC
This test case with 2.059head does not raise errors, but std.format still has an issue.

Reduced test case:

struct Foo {
    int[] bar;
    alias bar this;
}
void main()
{
    import std.format;
    import std.array;

    auto w = appender!string();
    FormatSpec!char f;
    Foo foo;
    formatValue(w, foo, f);    // OK
    formatValue(w, Foo(), f);  // NG
}