I would like to discuss this one as well. I have hit a couple of cases
including in Nim compiler itself when this features would have bern rather
helpful. So it is potentially good addition to Nim as RFC.
Obviously, the following should not compile, because bar is out of position:
type
FooKind = enum a, b, c
Foo = object
case kind: FooKind
of a:
bar, a: int
of b:
b, bar: int
of c:
c: int
Run
While the following can:
type
FooKind = enum a, b, c
Foo = object
case kind: FooKind
of a:
bar, a: int
of b:
bar, b: int
of c:
c: int
Run
Codegen should not be a problem. IsFieldAccessible check would become more
involved though.
@Araq, what do you think? Is it worth an RFC?