diff --git a/compiler/vm.nim b/compiler/vm.nim index 246d9d4d23..ba14f2d51b 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -711,7 +711,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of opcLdObj: # a = b.c decodeBC(rkNode) - let src = regs[rb].node + let src = if regs[rb].kind == rkNode: regs[rb].node else: regs[rb].nodeAddr[] case src.kind of nkEmpty..nkNilLit: # for nkPtrLit, this could be supported in the future, use something like: diff --git a/tests/vm/t17039.nim b/tests/vm/t17039.nim new file mode 100644 index 0000000000..f92c93f30a --- /dev/null +++ b/tests/vm/t17039.nim @@ -0,0 +1,10 @@ +type + Obj1 = object + case kind: bool + of false: + field: seq[int] + else: discard + +static: + var obj1 = Obj1() + obj1.field.add(@[])