summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-07-21 13:16:53 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-07-21 13:16:53 +0200
commitf485ebe1624656c0cf495baaebc5d45fdc9bdbeb (patch)
tree5c462e7836f027fc7371d6f589d3cb1b73b2bbed /compiler/cgen.nim
parent4389409e2657e4cec098180299b2d41b1a3a40f7 (diff)
downloadNim-f485ebe1624656c0cf495baaebc5d45fdc9bdbeb.tar.gz
--gc:destructors: next steps; WIP
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 8d8fdfcd9..80c03f9e4 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -334,7 +334,9 @@ proc resetLoc(p: BProc, loc: var TLoc) =
 
 proc constructLoc(p: BProc, loc: TLoc, isTemp = false) =
   let typ = loc.t
-  if not isComplexValueType(typ):
+  if p.config.selectedGc == gcDestructors and skipTypes(typ, abstractInst).kind in {tyString, tySequence}:
+    linefmt(p, cpsStmts, "$1.len = 0; $1.p = NIM_NIL;$n", rdLoc(loc))
+  elif not isComplexValueType(typ):
     linefmt(p, cpsStmts, "$1 = ($2)0;$n", rdLoc(loc),
       getTypeDesc(p.module, typ))
   else: