> But I don't understand how a __format_string annotation helps here. > > If you have code like this: > > string f = "%d"; > writeln(f, 10); > > Adding that annotation (here translated to a D annotation) doesn't help the > compiler much: > > @format_string string f = "%d"; > writeln(f, 10);
There's a bug there, the code needs to be: @format_string string f = "%d"; writefln(f, 10); In most cases you don't want to print a format string, so if you write: @format_string string f = "%d"; writeln(f, 10); The compiler is probably able to show a warning, that says that you are using a format string as first argument of a printing function that doesn't use a format string :-) And this warning is enough to catch that bug. Bye, bearophile