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 605627 - Unability to read length of a property of array type
Unability to read length of a property of array type
Status: RESOLVED DUPLICATE of bug 585847
Product: vala
Classification: Core
Component: Objects
0.7.x
Other Linux
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-12-28 20:46 UTC by Aleksander Wabik
Modified: 2010-01-08 20:37 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Aleksander Wabik 2009-12-28 20:46:17 UTC
Testcase:

//-----------------
namespace Test
{
	public class Obj
	{
		public int[] prop {get; private set;}
		public int[] variable;
		public Obj(int i)
		{
			prop = new int[i];
		}
	}
}
 
void main()
{
	Test.Obj ob = new Test.Obj(5);
	int len = ob.prop.length;
}
//-----------------

Fragment of generated C code: function _main():

//-----------------
void _main (void) {
	TestObj* ob;
	gint _tmp0_;
	gint len;
	ob = test_obj_new (5);
	len = _tmp0_;
	_test_obj_unref0 (ob);
}
//-----------------

Clearly you can see, that variable len is assigned with uninitialized helper variable, and it should be assigned with length of array accessible by property getter.

This bug may be related to #600564.

This bug has the same workaround as #600564:

var prop_length = ob.prop;
int len = prop_length.length;
Comment 1 Jürg Billeter 2010-01-08 20:37:31 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

*** This bug has been marked as a duplicate of bug 585847 ***