Namespace with certain identifiers creates invalid C code
Submitted by Michael 'Mickey' Lauer
Link to original bug (#790239)
Description
I see two issues here:
namespace 123x { const int a = 42; }
int main() {
return 0;
}
% valac -c y.vala
/tmp/y.vala.c:11:9: error: macro name must be an identifier
#define 123X_a 42
^
1 error generated.
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Obviously this "acceptable" Vala program creates invalid C code, whereas it should rather emit a Vala error, since 123x is not a legal identifier (identifiers in Vala which start w/ digits have to be escaped).
However, trying to make it a legal identifier by adding the '@' does not cut it either:
namespace @123x { const int a = 42; }
int main() {
return 0;
}
% valac -c y.vala /tmp/y.vala.c:11:9: error: macro name must be an identifier #define 123X_a 42 ^ 1 error generated. error: cc exited with status 256