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 727927 - Unary +/- can't be used for enums
Unary +/- can't be used for enums
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Semantic Analyzer
unspecified
Other Linux
: Normal minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-10 00:24 UTC by Simon Werbeck
Modified: 2018-05-22 15:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Negation of enum fails (131 bytes, text/x-vala)
2014-04-10 00:24 UTC, Simon Werbeck
  Details
Support negation of enums (677 bytes, patch)
2014-04-10 00:29 UTC, Simon Werbeck
none Details | Review
Support negation of enums (1.62 KB, patch)
2014-04-10 07:00 UTC, Simon Werbeck
none Details | Review

Description Simon Werbeck 2014-04-10 00:24:24 UTC
Created attachment 273948 [details]
Negation of enum fails

The attached test case fails to compile with the error "Operator not supported for `Direction'". I think Vala should support this since writing (-1 * d) works as expected.
Comment 1 Simon Werbeck 2014-04-10 00:29:07 UTC
Created attachment 273949 [details] [review]
Support negation of enums

Fixes bug 727927
Comment 2 Simon Werbeck 2014-04-10 07:00:46 UTC
Created attachment 273957 [details] [review]
Support negation of enums

The previous patch contained only the testcase, this is the actual fix.
Comment 3 Luca Bruno 2014-04-10 07:51:09 UTC
This is not a good operation for enums. The + and - are supposed to return a value in the same domain, which is not the case for enums. If you want + and -, cast to int.
Comment 4 Simon Werbeck 2014-04-10 08:56:17 UTC
Ok that makes sense, but then the bug is at the binary operations, consider the following:

var foo = Some.FOO;
var bar = foo * 5;

ccode:
Foo foo = 0;
Foo bar = 0;
foo = SOME_FOO;
bar = foo * 5;  // should have int as result type
Comment 5 Luca Bruno 2014-04-10 09:20:46 UTC
Yes never liked that, with enums I'd allow only bitwise operators. However that can't be changed anymore.
Comment 6 GNOME Infrastructure Team 2018-05-22 15:08:05 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/441.