GNOME Bugzilla – Bug 691319
Variables using C keyword names are allowed in Vala, but not C
Last modified: 2018-05-22 14:40:06 UTC
Created attachment 232948 [details] Example Vala progam using keywords In Vala you can name variables using C keywords and this is allowed in Vala but not when the generated C code is compiled, e.g. $ valac keywords.vala /home/bob/git/vala/keywords.vala.c:29:10: error: expected identifier or ‘(’ before ‘break’ /home/bob/git/vala/keywords.vala.c:30:10: error: expected identifier or ‘(’ before ‘case’ /home/bob/git/vala/keywords.vala.c:31:15: warning: declaration does not declare anything [enabled by default] /home/bob/git/vala/keywords.vala.c:32:10: error: expected identifier or ‘(’ before ‘continue’ /home/bob/git/vala/keywords.vala.c:33:10: error: expected identifier or ‘(’ before ‘default’ /home/bob/git/vala/keywords.vala.c:34:10: error: expected identifier or ‘(’ before ‘do’ /home/bob/git/vala/keywords.vala.c:35:10: error: expected identifier or ‘(’ before ‘else’ /home/bob/git/vala/keywords.vala.c:36:14: error: expected ‘{’ before ‘;’ token /home/bob/git/vala/keywords.vala.c:36:10: error: two or more data types in declaration specifiers /home/bob/git/vala/keywords.vala.c: In function ‘_vala_main’: /home/bob/git/vala/keywords.vala.c:303:5: error: expected identifier before ‘break’ /home/bob/git/vala/keywords.vala.c:304:5: error: expected identifier before ‘case’ /home/bob/git/vala/keywords.vala.c:305:5: error: expected identifier before ‘const’ ...
Ideally you would be able to use these keywords and they would be mangled when converting to C. If not, I would expect the compiler to not allow them to be used.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/349.