Wiki

Ticket #369 (new defect)

Opened 11 years ago

Last modified 11 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:

Description

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.

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

Change History

Changed 11 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.