Bug 11606 – Cannot instantiate Tuple of non printable
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-26T01:59:00Z
Last change time
2013-12-16T14:07:45Z
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2013-11-26T01:59:38Z
//----
import std.typecons;
class Foo{}
void main()
{
Tuple!(immutable(Foo)) a;
}
//----
src\phobos\std\format.d(2619): Error: template instance formatObject!(Appender!string, immutable(Foo), char) does not match template declaration formatObject(Writer, T, Char)(ref Writer w, ref T val, ref FormatSpec!Char f) if (hasToString!(T, Char))
src\phobos\std\format.d(2382): Error: template instance std.format.formatValue!(Appender!string, immutable(Foo), char) error instantiating
src\phobos\std\typecons.d(570): instantiated from here: formatElement!(Appender!string, immutable(Foo), char)
//----
This is problematic, in the sense that we never even made a call to print. We just declared the tuple.
Root issue:
https://d.puremagic.com/issues/show_bug.cgi?id=11605
Workaround:
Make toString() implementation conditional:
https://github.com/D-Programming-Language/phobos/pull/1724