summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-02-07 06:58:57 +0100
committerGitHub <noreply@github.com>2020-02-07 06:58:57 +0100
commitc87796180edc86cf3cc1fa0fb35f03c1461937cd (patch)
treec5a7195e99bfea2ccac9782750ac786d22ba0936 /compiler
parent7481f4375303f3bf41ec1d7f685283e558856531 (diff)
downloadNim-c87796180edc86cf3cc1fa0fb35f03c1461937cd.tar.gz
fixes #13269 (#13344)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/liftdestructors.nim9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index 3671f62b8..377ba149a 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -93,8 +93,8 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool)
     # XXX This is only correct for 'attachedSink'!
     var localEnforceDefaultOp = enforceDefaultOp
     if c.kind == attachedSink:
-      ## the value needs to be destroyed before we assign the selector
-      ## or the value is lost
+      # the value needs to be destroyed before we assign the selector
+      # or the value is lost
       let prevKind = c.kind
       c.kind = attachedDestructor
       fillBodyObj(c, n, body, x, y, enforceDefaultOp = false)
@@ -704,7 +704,10 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
       defaultOp(c, t, body, x, y)
   of tyObject:
     if not considerUserDefinedOp(c, t, body, x, y):
-      fillBodyObjT(c, t, body, x, y)
+      if c.kind in {attachedAsgn, attachedSink} and t.sym != nil and sfImportc in t.sym.flags:
+        body.add newAsgnStmt(x, y)
+      else:
+        fillBodyObjT(c, t, body, x, y)
   of tyDistinct:
     if not considerUserDefinedOp(c, t, body, x, y):
       fillBody(c, t[0], body, x, y)