Bug 9780 – Maybe bad formatted write of array of 2-tuples

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-21T11:26:27Z
Last change time
2019-11-14T12:35:04Z
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-03-21T11:26:27Z
This is wrong code because %(...%) is currently not supposed to be able to unpack a tuple: import std.stdio: writefln; import std.typecons: tuple; void main() { auto data = [tuple(1, 2), tuple(3, 4), tuple(5, 6)]; writefln("%(%s %s\n%)", data); } DMD 2.063alpha prints: Tuple!(int, int)(1, 2) %s Tuple!(int, int)(3, 4) %s Tuple!(int, int)(5, 6) I am not sure, but I think the printing of "%s" is a bug. I think that program should raise a formatting error like in this case: import std.stdio: writefln; import std.typecons: tuple; void main() { writefln("%s %s", tuple(1, 2)); } std.format.FormatException@C:\dmd2\src\phobos\std\format.d(431): Orphan format specifier: %%s %s (Generally I hate D/DMD to not give compile-time errors for this. But this is a different topic.)
Comment #1 by bugzilla — 2019-11-14T12:35:04Z
Seems to be fixed with latest version of dmd...