summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-12-06 15:38:53 -0600
committerAndreas Rumpf <rumpf_a@web.de>2019-12-06 22:38:53 +0100
commit23fc93fc2d0e409fba92ddbb02772d4ba5bb9c0f (patch)
tree5284b43541f9e88915a57ddf209718a74ca209d8 /compiler
parent7213969901a4232013a6e6732d7b434970922510 (diff)
downloadNim-23fc93fc2d0e409fba92ddbb02772d4ba5bb9c0f.tar.gz
VM: allow ptr setting ptr fields (#12825)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/vm.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index e16324355..4403a385d 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -231,7 +231,11 @@ proc fastAsgnComplex(x: var TFullReg, y: TFullReg) =
 proc writeField(n: var PNode, x: TFullReg) =
   case x.kind
   of rkNone: discard
-  of rkInt: n.intVal = x.intVal
+  of rkInt:
+    if n.kind == nkNilLit:
+      n[].reset
+      n.kind = nkIntLit # ideally, `nkPtrLit`
+    n.intVal = x.intVal
   of rkFloat: n.floatVal = x.floatVal
   of rkNode: n = copyValue(x.node)
   of rkRegisterAddr: writeField(n, x.regAddr[])