History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-775
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Marcus Griep
Reporter: David Piepgrass
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Boo

~ (bitwise not operator) cannot be used on an enum

Created: 13/Oct/06 08:11 PM   Updated: 16/Nov/06 09:43 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 0.7.7

Time Tracking:
Not Specified

File Attachments: 1. File BCE0051-2.boo (1 kb)
2. File EnumOperationsTestFixture.boo (3 kb)
3. Text File Enums.patch (410 kb)
4. Text File Enums.patch (91 kb)
5. File example.boo (0.1 kb)
6. Text File ProcessMethodBodies.cs (155 kb)
7. Text File TypeSystemServices.cs (42 kb)
8. Text File TypeSystemServices.cs (42 kb)
9. Text File UnfoldConstants.cs (6 kb)
10. Text File UnfoldConstants.cs (5 kb)

Issue Links:
Duplicate
 
Related
 


 Description  « Hide
~ (bitwise not operator) cannot be used on an enum, even with 'Flags' attribute. It should be possible to remove a flag as follows:

x = SomeEnum.Value1 | SomeEnum.Value2
x &= ~SomeEnum.Value1



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Marcus Griep - 11/Nov/06 11:05 PM
Here is my current progress on this issue. As it stands, it works for (unary - ~) | & + - but it also works for other integer operations (such as * / %), which it shouldn't. I will be working on fixing this as my next objective.

Also, while (unary ~) | & return an appropriate Enum, + -, etc return type Int32. This is the incorrect return type (it should be an enum, even if it is an invalid value for that enum). This will be my next objective.

I've posted the unified diff and the two current source files I've modified. I still need to understand more on how the expression type is determined, and how to make the appropriate modification.


Marcus Griep - 15/Nov/06 09:17 PM
The most recently attached (Nov 15) patch and other files are the most recent fixes to this problem. Enum operations now implement the ECMA standard.

http://www.ecma-international.org/publications/standards/Ecma-334.htm

The only caveat is that all enums defined in boo are of type Int32, while enums defined outside of boo can be any integer type. Therefore, when boo supports inspecting the underlying type of the enums, the standard can be more strictly adhered to (in the case of enum addition and subtraction).