On Saturday, 21 April 2018 at 22:34:39 UTC, Steven Schveighoffer
wrote:
I just came across this. Can't believe there's not been more
people finding this:
char[] buf = new char[100];
buf.formattedWrite("This is a number: %s", 5); // Error cannot
put a const(char)[] into a char[]
OK, challenge accepted!
buf[0 .. myName.length] = myName[]; // Hey phobos, look, this
is easy!
But no, of course -- autodecoding. >:(
https://issues.dlang.org/show_bug.cgi?id=18790
-Steve
"Use .representation" would be the official answer for the second
hack.
But this should absolutely work. It looks this looks the same
thing as
https://issues.dlang.org/show_bug.cgi?id=18472#c10
---
enum s = "%1$s,%2$s".format("foo","bar");
---
phobos/std/range/primitives.d(405): Error: static assert:
"Cannot put a const(char)[] into a Appender!string."
phobos/std/format.d(1184): instantiated from here:
put!(Appender!string, const(char)[])
/phobos/std/format.d(473): instantiated from here:
writeUpToNextSpec!(Appender!string)
phobos/std/format.d(6168): instantiated from here:
formattedWrite!(Appender!string, char, string, string)
main.d(5): instantiated from here: format!(char, string,
string)
18472 broke compilation of DCompute under -betterC when upgrading
LDC to a newer DMDFE, I "fixed" it by not compiling with -betterC
but then Mike Franklin (thanks!) discovered the above error after
fixing the -betterC side of things.
I'm going to be extremely unhappy if I can't compile dcompute at
all with the latest LDC.
IMO this is a priority 1 regression.