After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 598869 - Critical compiler error for delegate method
Critical compiler error for delegate method
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Delegates
0.7.x
Other Linux
: Normal normal
: 0.38
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-18 20:53 UTC by Rikard Nordgren
Modified: 2017-06-21 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Rikard Nordgren 2009-10-18 20:53:31 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.
Comment 1 Frederik Sdun 2010-09-14 15:53:09 UTC
I think vala should throw an error for this case, because you need an instance of the type to assign the delegate.
Comment 2 Rico Tzschichholz 2017-06-21 13:48:34 UTC
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