[Vala] Default Arguments to Functions



Hi there,

I think I may have found a bug in valac concerning default arguments to
functions.

I'm wondering if what I am doing is wrong, or whether its allowed.

Thanks,
Sam




The following code compiles into incorrect C:

void do_something(uint8[] array1,
                  uint8[] array2,
                  int len = int.min(array1.length, array2.length))
{
    // Do something
}

int main(string[] args)
{
    uint8[] a1 = new uint8[5];
    uint8[] a2 = new uint8[6];
    
    do_something(a1, a2);
    
    return 0;
}

I get the following errors:

In function ‘_vala_main’:
error: ‘array1_length1’ undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: ‘array2_length1’ undeclared (first use in this function)





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