[Vala] bug in sugar syntax



Hi all
I use valac version 0.24.0.
When I use operator "+=" with a class that has sugar syntax support for
operator "[]" the compiler produces wrong C code.
Example:

using Gee;
void main()
{
    ArrayList<int> a = new ArrayList<int>();
    a.add(2);
    print(@"a[0] = $(a[0])\n");
    a[0] = a[0] + 1;
    print(@"a[0] = $(a[0])\n");
    a[0] += 1;
    print(@"a[0] = $(a[0])\n");
}

This will output 2, 3, 1 instead of 2, 3, 4 as intended.

I do not know if it is fixed in more current valac versions.

--Luca


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]