Ticket #379 (new defect)
enum of int8/uint8: translation wrong
Reported by: | thriwkin | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | Cobra Compiler | Version: | 0.9.6 |
Keywords: | enum | Cc: |
Description
If an enum is declared with an underlying type of int8 or uint8
then the translation to C# is incorrect:
- int8 is translated to byte instead of sbyte
-- without any message! - uint8 is translated to ubyte instead of byte,
and the C# compiler gives this message:
"error: CS1008: Type byte, sbyte, short, ushort, int, uint, long, or ulong expected".
This program should compile and run:
enum EnumOfInt8 of int8 A, B, C enum EnumOfUInt8 of uint8 A, B, C class Program def main is shared t = Enum.getUnderlyingType(EnumOfInt8.getType) print t assert t is int8 assert t is System.SByte t = Enum.getUnderlyingType(EnumOfUInt8.getType) print t assert t is uint8 assert t is System.Byte
That of int8 is quietly translated incorrectly can cause a lot of trouble, especially in a large program.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.