After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691319 - Variables using C keyword names are allowed in Vala, but not C
Variables using C keyword names are allowed in Vala, but not C
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Parser
0.18.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-01-08 00:40 UTC by Robert Ancell
Modified: 2018-05-22 14:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example Vala progam using keywords (2.96 KB, text/x-vala)
2013-01-08 00:40 UTC, Robert Ancell
Details

Description Robert Ancell 2013-01-08 00:40:16 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’
...
Comment 1 Robert Ancell 2013-01-08 00:41:39 UTC
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.
Comment 2 GNOME Infrastructure Team 2018-05-22 14:40:06 UTC
-- 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.