Support to set the type of initializer
Vala now cannot set the type of the initializer. I don't know whether it's a bug or a feature, but C supports this:
wchar_t * s = (wchar_t[]) {20320, 22909, 65292, 19990, 30028, 65281, 10, 0};
And it's the same as:
wchar_t tmp[] = {20320, 22909, 65292, 19990, 30028, 65281, 10, 0};
wchar_t * s = (wchar_t *) tmp;
Maybe Vala can support this:
#!/usr/bin/env -S vala -X -O2 -X -march=native --cc="ccache cc" -X -pipe -X -fuse-ld=mold
struct Pos {
int x;
int y;
int z;
}
void main () {
var foo = (Pos) {1, 1, 1};
// The same as:
//
// Pos foo = {1, 1, 1};
string16 bar = (unichar2[]) {20320, 22909, 65292, 19990, 30028, 65281, 10, 0};
// The same as:
//
// string16 bar = (string16) new unichar2[] {20320, 22909, 65292, 19990, 30028, 65281, 10, 0};
}
Edited by Zhou Qiankang