The following code:

  int guess;
  readln().formattedRead!"%d"(guess);

produces the following compiler error:

Error: template std.format.formattedRead cannot deduce function from argument types !("%s")(string, int), candidates are: /usr/include/dmd/phobos/std/format.d(635): std.format.formattedRead(alias fmt, R, S...)(ref R r, auto ref S args) if (isSomeString!(typeof(fmt))) /usr/include/dmd/phobos/std/format.d(644): std.format.formattedRead(R, Char, S...)(ref R r, const(Char)[] fmt, auto ref S args)

That is odd! I expected this to match:

  uint formattedRead(alias fmt, R, S...)(ref R r, auto ref S args)

However, the following works!!!

  int guess;
  string line = readln();
  line.formattedRead!"%d"(guess);


This definitely looks like a bug, but I want to confirm first before filing one.

Reply via email to