GNOME Bugzilla – Bug 433296
list.copy().reverse() confuses vala
Last modified: 2008-10-18 14:06:39 UTC
Please describe the problem: It seems that Vala gets confused trying to manage the memory of SList rev_indices = indices.copy().reverse(); where "indices" is an SList. I would expect this to be valid Vala code, but the output C code is: GSList* rev_indices = (__temp3 = (__temp2 = g_slist_copy (indices)) = g_slist_reverse ((__temp2 = g_slist_copy (indices))), (__temp2 == NULL ? NULL : (__temp2 = (g_slist_free (__temp2), NULL))), __temp3); which obviously fails to compile with gcc (invalid lvalue in assignment). Steps to reproduce: Try to compile the vala code mentioned above. Actual results: gcc fails with invalid lvalue in assignment, as expected given the generated C code. Expected results: It should look something like this: GSList* rev_indices = g_slist_reverse ((__temp2 = g_slist_copy (indices))); Does this happen every time? yes Other information:
Your example is invalid code as GLib.List.reverse doesn't have a return value, see bug 434503 Your bug is still valid as the following statement shouldn't cause any problems, it doesn't make much sense, though. indices.copy().reverse(); This should work fine: SList rev_indices = indices.copy (); rev_indices.reverse ();
Ok, thanks for pointing that out. I got confused between C and Vala.
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
test case added to vala-tests