Bug 4754 – format and Format!() do not work with posix positional parameters
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-08-29T03:29:00Z
Last change time
2012-04-10T03:38:13Z
Assigned to
andrei
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2010-08-29T03:29:49Z
The following program fails to compile:
import std.metastrings;
import std.stdio;
void main()
{
mixin(Format!("writeln(\"%1$s\");", "hello world"));
}
Instead, you get this error:
/path/to/src/phobos/std/metastrings.d(69): Error: static assert "unrecognized format %1"
/path/to/src/phobos/std/metastrings.d(51): 11 recursive instantiations from here: FormatString!("writeln(\"%1$s\");","hello world")
d.d(6): instantiated from here: Format!("writeln(\"%1$s\");","hello world")
So, it would appear that Format!() fails to work with posix positional parameters. If you replace %1$s with %s, it works just fine. Also, if you attempt to use format() with %1$s, it throws a FormatError at runtime. I would expect that format and Format!() would accept exactly the same types of input as writefln(). However, that does not appear to currently be the case. Certainly, having them differ in capabilities is going to cause a fair bit of confusion. So, they need to be fixed to work with the same input as writefln(). In particular, they need to support posix positional parameters.
Comment #1 by smjg — 2012-04-10T03:38:13Z
*** This issue has been marked as a duplicate of issue 4532 ***