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 433296 - list.copy().reverse() confuses vala
list.copy().reverse() confuses vala
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.1.x
Other All
: Normal minor
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2007-04-25 12:50 UTC by Michael Lawrence
Modified: 2008-10-18 14:06 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Lawrence 2007-04-25 12:50:33 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:
Comment 1 Jürg Billeter 2007-04-30 06:52:27 UTC
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 ();
Comment 2 Michael Lawrence 2007-04-30 12:04:42 UTC
Ok, thanks for pointing that out. I got confused between C and Vala.
Comment 3 Jürg Billeter 2007-11-29 15:37:30 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
Comment 4 Marc-Andre Lureau 2008-10-18 14:06:39 UTC
test case added to vala-tests