Compilation error with array
I've found a bug that, when a class is trying to use a global array on certain conditions (accessing an array inside another namespace), it can't compile the code. There seems to be a lacking _myArray_size_
variable in the generated C code.
I've attached a very simple reproduction case: vala-bug.zip
Output:
$ valac Test.vala Main.vala
...
/tmp/vala-bug/Main.vala.c: In function ‘main_main’:
/tmp/vala-bug/Main.vala.c:32:2: error: ‘_main_test_globalStringArray_size_’ undeclared (first use in this function); did you mean ‘main_test_globalStringArray’?
32 | _main_test_globalStringArray_size_ = main_test_globalStringArray_length1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| main_test_globalStringArray
/tmp/vala-bug/Main.vala.c:32:2: note: each undeclared identifier is reported only once for each function it appears in
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Test.vala
namespace Main.Test {
string[] globalStringArray;
}
Main.vala
using Test;
namespace Main {
public static void main(string[] args) {
Test.globalStringArray = {"a"};
}
}