GNOME Bugzilla – Bug 585847
The length property of array properties is not correctly retrieved.
Last modified: 2010-10-14 14:44:25 UTC
class AClass { private int[] _array = new int[] {1, 2, 3}; public int[] array { get {return this._array;} } } var a = new AClass (); stdout.printf ("%d\n", a.array.length); "3" should be print on the screen, however "0" is displayed. Here is the C code: AClass* a; gint _tmp0_; a = aclass_new (); fprintf (stdout, "%d\n", _tmp0_);
Confirming.
*** Bug 593859 has been marked as a duplicate of this bug. ***
The foreach statement seems to get this right, hence for your viewing pleasure here's the ugly workaround: var length = 0; foreach ( var element in array ) { length++; }
There is an easier workaround: var arr = a.array; stdout.printf ("%d\n", arr.length);
*** Bug 605627 has been marked as a duplicate of this bug. ***
commit 5226feafef569a54d88c71468edf03eb99345ff2 Author: Jürg Billeter <j@bitron.ch> Date: Thu Oct 14 16:43:17 2010 +0200 codegen: Use separate C statements for property access Fixes bug 585847.