summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-07-02 21:15:29 +0200
committerAraq <rumpf_a@web.de>2014-07-02 21:15:29 +0200
commit21be7bf85a4d8cdff1acfcc5c8b9bf9c0727b290 (patch)
treef48c70ad378b679b60cc04b3bd3fc6bedfb5d5ef /compiler/vmgen.nim
parent887a1ebe688a01259263ad6e11c9061cfc940456 (diff)
downloadNim-21be7bf85a4d8cdff1acfcc5c8b9bf9c0727b290.tar.gz
fixes #1310
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r--compiler/vmgen.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 3819bed98..28e0a8fd6 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -14,7 +14,12 @@
 #   assignments ('x = y'). For simple data types that fit into a register
 #   this doesn't matter. However it matters for strings and other complex
 #   types that use the 'node' field; the reason is that slots are
-#   re-used in a register based VM. XXX Come up with an example.
+#   re-used in a register based VM. Example:
+# 
+# .. code-block:: nimrod
+#   let s = a & b  # no matter what, create fresh node
+#   s = a & b  # no matter what, keep the node
+#   
 
 import
   unsigned, strutils, ast, astalgo, types, msgs, renderer, vmdef, 
@@ -1335,6 +1340,8 @@ proc genVarSection(c: PCtx; n: PNode) =
         if a.sons[2].kind == nkEmpty:
           c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
         else:
+          if not fitsRegister(s.typ):
+            c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
           gen(c, a.sons[2], s.position.TRegister)
     else:
       # assign to a.sons[0]; happens for closures