fixes #22613; Default value does not work with object's discriminator (#22614)

* fixes #22613; Default value does not work with object's discriminator

fixes #22613

* merge branches

* add a test case

* fixes status

* remove outdated comments

* move collectBranchFields into the global scope
This commit is contained in:
ringabout
2023-09-01 14:55:19 +08:00
committed by GitHub
parent 3b206ed988
commit affd3f7858
2 changed files with 59 additions and 24 deletions

View File

@@ -377,7 +377,7 @@ template main {.dirty.} =
Red, Blue, Yellow
type
ObjectVarint3 = object # fixme it doesn't work with static
ObjectVarint3 = object
case kind: Color = Blue
of Red:
data1: int = 10
@@ -703,5 +703,20 @@ template main {.dirty.} =
var foo = new Container
doAssert int(foo.thing[0].x) == 1
block: # bug #22613
type
K = enum
A = "a"
B = "b"
T = object
case kind: K = B
of A:
a: int
of B:
b: float
doAssert T().kind == B
static: main()
main()