Ticket #369 (new defect)

Opened 5 years ago

Last modified 5 years ago

Assigning values to enums out-of-order does not work

Reported by: NoshBar Owned by:
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.9.6
Keywords: enum Cc:


This may be an abuse of enums, but I am setting up some default values in my app through the use of enums, and I noticed that assigning them values directly does not work if they are not in numerical order. I do not receive a warning or error during compilation.

class Test
..enum Defaults
....HalfAMillion = 500000,
....Zero = 0
..def main
....print Defaults.Zero to int #actually prints 500001

Change History

Changed 5 years ago by hopscc

Something to do with the zero init
( the initilisation isnt being passed through to codegen)
Initing to anything else works fine.

class Test
        enum Defaults
                HalfAMillion = 500000
                Zero = 0
                Wun = 1

        def main
                print Defaults.Zero, Defaults.Zero to int # actually prints 500001
                print Defaults.Wun, Defaults.Wun to int   # prints 1 correctly
Note: See TracTickets for help on using tickets.