valac crashes when passing e.g. Gtk.Widget.destroy to a function
When compiling e.g. the following code:
int main (string[] args) {
var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
box.foreach (Gtk.Widget.destroy);
return 0;
}
valac
crashes with the following output:
(valac:105840): vala-ccode-CRITICAL **: 09:19:18.118: vala_ccode_function_call_add_argument: assertion 'expr != NULL' failed
error: Unresolved type reference
**
vala-ccodegen:ERROR:valaccodemethodcallmodule.c:3325:vala_ccode_method_call_module_real_visit_method_call: assertion failed: (delegate_target != null)
Bail out! vala-ccodegen:ERROR:valaccodemethodcallmodule.c:3325:vala_ccode_method_call_module_real_visit_method_call: assertion failed: (delegate_target != null)
Aborted (core dumped)
The core dump has the following backtrace:
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007f7a92c68537 in __GI_abort () at abort.c:79
#2 0x00007f7a92f74dd3 in () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3 0x00007f7a92fd076b in g_assertion_message_expr () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4 0x00007f7a92ea98f6 in vala_ccode_method_call_module_real_visit_method_call
(base=<optimized out>, expr=expr@entry=0x56455539c6d0) at valaccodemethodcallmodule.c:3325
#5 0x00007f7a92eee172 in vala_gtype_module_real_visit_method_call (base=0x564550372770, expr=0x56455539c6d0)
at valagtypemodule.c:13912
#6 0x00007f7a92ee9003 in vala_gsignal_module_real_visit_method_call (base=0x564550372770, expr=expr@entry=0x56455539c6d0)
at valagsignalmodule.c:4032
#7 0x00007f7a92ebd8f3 in vala_gd_bus_client_module_real_visit_method_call (base=0x564550372770, expr=0x56455539c6d0)
at valagdbusclientmodule.c:1583
#8 0x00007f7a92ed0e93 in vala_gd_bus_server_module_real_visit_method_call (base=0x564550372770, expr=0x56455539c6d0)
at valagdbusservermodule.c:6092
#9 0x00007f7a931b81f7 in vala_method_call_real_emit (base=0x56455539c6d0, codegen=0x564550372770) at valamethodcall.c:3634
#10 0x00007f7a9314f5b2 in vala_expression_statement_real_emit (base=0x56455539eb60, codegen=0x564550372770)
at valaexpressionstatement.c:247
#11 0x00007f7a92e84824 in vala_ccode_base_module_real_visit_block (base=<optimized out>, b=0x56455538fb10)
at valaccodebasemodule.c:13215
#12 0x00007f7a92eb11fc in vala_ccode_method_module_real_visit_method (base=0x564550372770, m=<optimized out>)
at valaccodemethodmodule.c:4175
#13 0x00007f7a92ee525d in vala_gtk_module_real_visit_method (base=0x564550372770, m=0x564555327de0) at valagtkmodule.c:1713
#14 0x00007f7a931c3ee9 in vala_object_type_symbol_real_accept_children (base=0x56455519aa10, visitor=0x564550372770)
at valaobjecttypesymbol.c:1078
#15 0x00007f7a9312801c in vala_class_real_accept_children (base=0x56455519aa10, visitor=0x564550372770) at valaclass.c:1356
#16 0x00007f7a92efc059 in vala_gtype_module_real_visit_class (base=0x564550372770, cl=0x56455519aa10)
at valagtypemodule.c:3800
#17 0x00007f7a92ee17d2 in vala_gobject_module_real_visit_class (base=0x564550372770, cl=0x56455519aa10)
at valagobjectmodule.c:109
#18 0x00007f7a92ec82bf in vala_gd_bus_module_real_visit_class (base=0x564550372770, cl=0x56455519aa10)
at valagdbusmodule.c:3480
#19 0x00007f7a92ed186f in vala_gd_bus_server_module_real_visit_class (base=0x564550372770, cl=0x56455519aa10)
at valagdbusservermodule.c:6317
#20 0x00007f7a93208f58 in vala_source_file_accept_children (self=<optimized out>, visitor=0x564550372770)
at valasourcefile.c:673
#21 0x00007f7a92e6f517 in vala_ccode_base_module_real_visit_source_filePython Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.:
(base=0x564550372770, source_file=)
at valaccodebasemodule.c:3316
#22 0x00007f7a92e6bd3f in vala_ccode_base_module_real_emitPython Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.:
(base=0x564550372770, context=) at valaccodebasemodule.c:2365
#23 0x00005645500b074c in ()
#24 0x00005645500af0b1 in ()
#25 0x00007f7a92c69cca in __libc_start_main (main=
0x5645500aea50, argc=37, argv=0x7ffe865a59c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe865a59b8) at ../csu/libc-start.c:308
#26 0x00005645500af27a in ()
@ricotz says on IRC that "it should work, but vala needs to pick to correct symbol reference, in this case Gtk.Widget.destroy points to 3 incarnations method/vfunc/signal, so there seems to be some confusion and the prototype-access fails".