GNOME Bugzilla – Bug 781061
[PrintfFormat] generates invalid C code with functions with Error
Last modified: 2017-08-27 08:23:36 UTC
printf_func_with_error.vala: ----- [PrintfFormat] void print(bool ok, string format, ...) throws GLib.Error { var text = format.vprintf(va_list()); if (ok) stdout.printf("%s", text); else throw new GLib.IOError.FAILED(text); } void main() { print(false, "Error %s", "something"); } ----- $ valac --version Vala 0.36.0 $ valac --pkg gio-2.0 printf_func_with_error.vala printf_func_with_error.vala.c:17:1: error: format string argument is not a string type void print (gboolean ok, const gchar* format, GError** error, ...) G_GNUC_PRINTF(3,4); ^~~~ error: cc exited with status 256 Compilation failed: 1 error(s), 1 warning(s)
Created attachment 358501 [details] [review] codegen: Adjust format-index for printf/scanf-methods which throw errors If there is no explicit FormatArg annotation while this method throws an error, it is required to mark the parameter located right before ellipsis as format-arg to account for the parameter shifting caused by the inserted GError parameter.