June 27, 2013 [Issue 10489] New: Orphan format arguments exception/error for writeln unless they are | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10489 Summary: Orphan format arguments exception/error for writeln unless they are Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-06-27 12:20:04 PDT --- In DMD 2.064alpha this program compiles and runs with no errors, warnings or run-time exceptions: import std.stdio; void main() { writefln("%d %d", 1, 2, 3); } While this gives a run-time exception: import std.string; void main() { format("%d %d", 1, 2, 3); } std.format.FormatException@...\dmd2\src\phobos\std\string.d(2346): Orphan format arguments: args[2..3] To catch some programmer mistakes I suggest to turn this into an exception/error: writefln("%d %d", 1, 2, 3); But as stated by Andrei Alexandrescu: http://forum.dlang.org/post/kqgna8$1ese$1@digitalmars.com > The only point I'd negotiate would be to not throw with positional arguments, and throw with sequential arguments. All code that cares uses positional specifiers anyway. So according to Andrei this should be accepted: import std.stdio; void main() { writefln("%2$s %1$s", 1, 2, 3); } Currently this is accepted (and it prints "A B10"), but I think it should be not accepted: import std.stdio; void main() { writefln("A%2$s B%1$s", 10); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2013 [Issue 10489] Orphan format arguments exception/error for writeln unless they are | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=10489 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |DUPLICATE --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-29 20:05:48 PDT --- *** This issue has been marked as a duplicate of issue 4927 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation