Ticket #310 (new enhancement)

Opened 5 years ago

Last modified 5 years ago

enum check on compilation

Reported by: kobi7 Owned by:
Priority: major Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:


I would like to suggest a feature request:

when branching on an enum, I would like to get a warning if I omit in the 'on' cases one of the enum fields.
one warning for each field.
even if I have an 'else' case.

This is very useful when adding another field, it will let me know all the places in code that I should update.

((the current alternative is throwing a notsupported or notimplemented exception on the else case, which is then more easily discovered. or assert false in that position. however this is on runtime.))

Change History

Changed 5 years ago by Charles

I've thought about doing this before. I was planning on not throwing the error if there was an else. After all you wouldn't usually need the else if you had covered all the enums.

But I think we might also need a directive to disable this in specific cases.

Changed 5 years ago by hopscc

  • type changed from defect to enhancement
Note: See TracTickets for help on using tickets.