summary refs log tree commit diff stats
path: root/lib/core
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-20 16:06:18 +0800
committerGitHub <noreply@github.com>2020-11-20 09:06:18 +0100
commit6cf5ca1dc2c1c0388e0998a24d26f4a9c9b7e60e (patch)
tree2817d94f3319596aae1e87a7ea544c8d65ff7a02 /lib/core
parent109cc45398bcdafc22f0a5e49cdfda8234bc46de (diff)
downloadNim-6cf5ca1dc2c1c0388e0998a24d26f4a9c9b7e60e.tar.gz
alternative way to fix #16022 (#16064) [backport:1.4]
* alternative way to fix #16022
* add testcase for #16022

[backport:1.4]
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/typeinfo.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim
index 00f7c176c..ca531b4b9 100644
--- a/lib/core/typeinfo.nim
+++ b/lib/core/typeinfo.nim
@@ -327,10 +327,10 @@ proc setPointer*(x: Any, y: pointer) =
   ## ``akString``, ``akCString``, ``akProc``, ``akRef``, ``akPtr``,
   ## ``akPointer``, ``akSequence``.
   assert x.rawType.kind in pointerLike
-  if y != nil:
+  if y != nil and x.rawType.kind != tyPointer:
     genericAssign(x.value, y, x.rawType)
   else:
-    cast[ppointer](x.value)[] = nil
+    cast[ppointer](x.value)[] = y
 
 proc fieldsAux(p: pointer, n: ptr TNimNode,
                ret: var seq[tuple[name: cstring, any: Any]]) =