Array slicing in nested conditional parentheses results in delimiter `]' missing
When performing array slicing in nested parentheses, the compiler will throw a error: syntax error, following expression/statement delimiter ']' missing
I tested this on the main branch.
$ valac --version
Vala 0.56.1.8-27d55
Attempting to compile:
int main (string[] args) {
string hello = args[0];
bool overzealous_parentheses = (hello[0:3] == "hey");
/*if (hello.length >= 3 && (hello[0:3] == "hey" || hello[0:3] == "hay")) {
print ("Right back at ya");
}*/
return 0;
}
Results in
$ valac Whoops.vala
Whoops.vala:3.44-3.44: error: syntax error, following expression/statement delimiter `]' missing
3 | bool overzealous_parentheses = (hello[0:3] == "hey");
|
Removing the outer parentheses avoids the compilation error. if (hello[0:3] == "hey")
works, but any nested parentheses around the slice causes the error.
I tried running ./autogen.sh --enable-debug
and G_DEBUG=fatal-criticals gdb --args valac Whoops.vala
, but after the compiler error I didn't have a backtrace.
Reading symbols from valac...
(gdb) r
Starting program: /usr/local/bin/valac Whoops.vala
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Whoops.vala:3.44-3.44: error: syntax error, following expression/statement delimiter `]' missing
3 | bool overzealous_parentheses = (hello[0:3] == "hey");
| ^
Compilation failed: 1 error(s), 0 warning(s)
[Inferior 1 (process 120360) exited with code 01]
(gdb) bt
No stack.