[Vala] array declaration



I have noticed that if you declare an array in a wrong way you get errors from the C compiler
instead of handling it at vala level.

should this syntax be supported? or we should just throw an error?

Here's the test case:

$ cat a.vala
#!/usr/bin/vala
void main () {
        // uint8[] foo = new uint8[16]; // OK
        uint8 foo[] = new uint8[16]; // FAIL
        print("%d\n", foo[0]);
}

$ vala a.vala
/tmp/a.vala.LDAGFV.c: In function '_vala_main':
/tmp/a.vala.LDAGFV.c:16:9: error: array size missing in '_tmp0_'
/tmp/a.vala.LDAGFV.c:19:9: error: array size missing in 'foo'
/tmp/a.vala.LDAGFV.c:20:16: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:20:6: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:22:6: error: incompatible types when assigning to type 'guint8[1]' from type 'void *'
error: cc exited with status 256


Thanks

--pancake



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