[Vala] ArrayList fails with double operation



Hi,

i played recently with ArrayLists and found an interesting behaviour but
look at the example-code

//------------------------
using Gee;

int main()
{
        var list = new ArrayList<double?>();
        list.add(3.0);
        list.add(2.0);
        stdout.printf("%f\n", list[0] + list[1]);
        return 0;
}
//------------------------

this should work normally if i understand the concepts right. But i get

:~> valac-0.12 test.vala --pkg gee-1.0
test.vala.c: In function ‘_vala_main’:
test.vala.c:49:18: error: invalid operands to binary + (have ‘gdouble *’
and ‘gdouble *’)
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

if i add casts to the list-get-functions then this code works

//------------------------
using Gee;

int main()
{
        var list = new ArrayList<double?>();
        list.add(3.0);
        list.add(2.0);
        stdout.printf("%f\n", (double) list[0] + (double) list[1]);
        return 0;
}
//------------------------

is this a problem with the generic nullable type? If i look at the
generated C-Sources then he tries to add two pointer.

Greets




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