This has snuck up on me a couple times. When I have an object variant type and I create a new instance, if I accidentally forget to intialize the discriminator field, because of the zero initialization, I get no compiler error.
So I've found that if I set the first enum variant to 1, it helps, though it requires that I remember to do it. Is this the best way to deal with this? In the future, we will see the compiler catch this?
Thanks!
Hmmm... had trouble getting that working, but I see that if I put the requiresInit pragma on the enum, it helps.
type
Kind {.requiresInit pure.} = enum
foo
bar