This commit is contained in:
Andreas Rumpf
2020-10-09 16:18:36 +02:00
committed by GitHub
parent 16e8005031
commit d430216288
2 changed files with 23 additions and 0 deletions

View File

@@ -719,6 +719,8 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
result.typ = n.typ
of nkBracketExpr: result = foldArrayAccess(m, n, g)
of nkDotExpr: result = foldFieldAccess(m, n, g)
of nkCheckedFieldExpr:
result = foldFieldAccess(m, n[0], g)
of nkStmtListExpr:
var i = 0
while i <= n.len - 2:

View File

@@ -223,3 +223,24 @@ type MyObj = object
var a = MyObj(kind: false, x0: 1234)
a.kind = true
doAssert(a.x1 == "")
block:
# bug #15532
type Kind = enum
k0, k1
type Foo = object
y: int
case kind: Kind
of k0: x0: int
of k1: x1: int
const j0 = Foo(y: 1, kind: k0, x0: 2)
const j1 = Foo(y: 1, kind: k1, x1: 2)
doAssert j0.y == 1
doAssert j0.kind == k0
doAssert j1.kind == k1
doAssert j1.x1 == 2
doAssert j0.x0 == 2