Bug 7628 – Regression with std.string format and alias this

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-02T06:05:00Z
Last change time
2012-03-08T22:54:45Z
Assigned to
nobody
Creator
admin

Comments

Comment #0 by admin — 2012-03-02T06:05:48Z
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 by bioinfornatics — 2012-03-02T06:07:50Z
I got same error as you on linux 64 with ldc2 and dmdfe 2.058
Comment #2 by k.hara.pg — 2012-03-02T06:22:09Z
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 #3 by admin — 2012-03-03T07:04:33Z
Comment #4 by k.hara.pg — 2012-03-03T08:29:31Z
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 }
Comment #5 by github-bugzilla — 2012-03-03T18:11:56Z
Comment #6 by k.hara.pg — 2012-03-03T18:15:15Z
Comment #7 by github-bugzilla — 2012-03-08T22:54:45Z