GNOME Bugzilla – Bug 598869
Critical compiler error for delegate method
Last modified: 2017-06-21 13:48:34 UTC
The following (problematic) program gives critical errors in the compiler: public class Test { public delegate void MyType (uint8 data); public MyType my_func; } public class Big { public void foo (uint8 data) { stdout.printf("%d\n", data); } public static int main(string[] args) { var t = new Test(); t.my_func = foo; t.my_func(28); return 0; } } The following errors are given: ** (valac:10518): CRITICAL **: vala_ccode_base_module_get_ccodenode: assertion `node != NULL' failed ** (valac:10518): CRITICAL **: vala_expression_get_value_type: assertion `self != NULL' failed ** (valac:10518): CRITICAL **: vala_data_type_get_data_type: assertion `self != NULL' failed ** (valac:10518): CRITICAL **: vala_ccode_assignment_construct: assertion `r != NULL' failed ** (valac:10518): CRITICAL **: vala_ccode_comma_expression_append_expression: assertion `expr != NULL' failed Making the method foo static fixes the compilation.
I think vala should throw an error for this case, because you need an instance of the type to assign the delegate.
commit 9e2cd62d98b212067c8b3c2c644bc56903109aee Author: Rico Tzschichholz <ricotz@ubuntu.com> Date: Fri Mar 24 07:56:25 2017 +0100 codegen: Don't allow assigning delegate if no target/closure is available