GNOME Bugzilla – Bug 643088
valac generates invalid C code for abstract variadic functions
Last modified: 2018-05-16 15:05:51 UTC
interface Foo { public abstract void bar(int param1, ...); } valac generates code below void foo_bar (Foo* self, gint param1, ...) { FOO_GET_INTERFACE (self)->bar (self, param1); } Should be void foo_bar (Foo* self, gint param1, ...) { va_list argv; va_start(argv, param1); FOO_GET_INTERFACE (self)->bar_va (self, param1, argv); va_end(argv); }
It shouldn't be allowed to define virtual/abstract methods with ellipsis.
Created attachment 372008 [details] [review] vala: Abstract and virtual methods may not be variadic The chain-up of the variadic parameter is not possible.
Attachment 372008 [details] pushed as 5fb5abc - vala: Abstract and virtual methods may not be variadic
This broke tracker: libtracker-data.vapi:66.3-66.46: error: Abstract and virtual methods may not be variadic. Use a `va_list' parameter instead of `...'. public abstract DBStatement create_statement (DBStatementCacheType cache_type, ...) throw s DBInterfaceError; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tracker-sparql-pattern.vala:47.11-49.88: error: var declaration not allowed with non-typed initializer tracker-sparql-pattern.vala:50.7-50.10: error: The name `stmt' does not exist in the context of `Tracker. Sparql.PredicateVariable.get_sql_query' stmt.bind_int (0, subject_id); ^^^^ tracker-sparql-pattern.vala:51.16-51.19: error: The name `stmt' does not exist in the context of `Tracker .Sparql.PredicateVariable.get_sql_query' cursor = stmt.start_cursor (); ^^^^ tracker-sparql-pattern.vala:95.10-97.87: error: var declaration not allowed with non-typed initializer tracker-sparql-pattern.vala:98.6-98.9: error: The name `stmt' does not exist in the context of `Tracker.S parql.PredicateVariable.get_sql_query' stmt.bind_int (0, object_id); ^^^^ tracker-sparql-pattern.vala:99.10-99.38: error: var declaration not allowed with non-typed initializer var cursor = stmt.start_cursor (); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tracker-sparql-pattern.vala:102.10-102.15: error: The name `cursor' does not exist in the context of `Tra cker.Sparql.PredicateVariable.get_sql_query' if (cursor != null) { ^^^^^^ tracker-sparql-pattern.vala:103.14-103.19: error: The name `cursor' does not exist in the context of `Tra cker.Sparql.PredicateVariable.get_sql_query' while (cursor.next ()) { ^^^^^^ tracker-sparql-pattern.vala:104.49-104.54: error: The name `cursor' does not exist in the context of `Tracker.Sparql.PredicateVariable.get_sql_query' var range = ontologies.get_class_by_uri (cursor.get_string (0)); ^^^^^^ tracker-sparql-query.vala:517.7-517.115: error: var declaration not allowed with non-typed initializer var stmt = iface.create_statement (no_cache ? DBStatementCacheType.NONE : DBStatementCacheType.SELECT, "%s", sql); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tracker-sparql-query.vala:524.6-524.9: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_int (i, 1); ^^^^ tracker-sparql-query.vala:526.6-526.9: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_int (i, 0); ^^^^ tracker-sparql-query.vala:531.5-531.8: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_int (i, (int) string_to_date (binding.literal + "T00:00:00Z", null)); ^^^^ tracker-sparql-query.vala:533.5-533.8: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_double (i, string_to_date (binding.literal, null)); ^^^^ tracker-sparql-query.vala:535.5-535.8: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_int (i, int.parse (binding.literal)); ^^^^ tracker-sparql-query.vala:537.5-537.8: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' stmt.bind_text (i, binding.literal); ^^^^ tracker-sparql-query.vala:542.10-542.13: error: The name `stmt' does not exist in the context of `Tracker.Sparql.Query.prepare_for_exec' return stmt; ^^^^ Compilation failed: 19 error(s), 0 warning(s)
(In reply to Michael Catanzaro from comment #4) > This broke tracker: > See https://bugzilla.gnome.org/show_bug.cgi?id=796104
(In reply to Rico Tzschichholz from comment #5) > (In reply to Michael Catanzaro from comment #4) > > This broke tracker: > > > > See https://bugzilla.gnome.org/show_bug.cgi?id=796104 OK, please just push directly next time, I was about to revert this. Thanks!