summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-08-09 23:07:53 +0200
committerAraq <rumpf_a@web.de>2015-08-09 23:07:53 +0200
commit50861792f447d1a5213fcc9ebbfefae6ee146830 (patch)
tree8b928e0f356677ddad44eaac7570027710e486ab
parent0fc43d3d950714d779221382bbb08775c508b4e9 (diff)
downloadNim-50861792f447d1a5213fcc9ebbfefae6ee146830.tar.gz
fixes #1329
-rw-r--r--compiler/vmgen.nim2
-rw-r--r--tests/vm/tstaticprintseq.nim12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 1bee9788a..6a59b3384 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -1105,6 +1105,8 @@ proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
   # nkAddr we must not use 'unneededIndirection', but for deref we use it.
   if not isAddr and unneededIndirection(n.sons[0]):
     gen(c, n.sons[0], dest, newflags)
+    if gfAddrOf notin flags and fitsRegister(n.typ):
+      c.gABC(n, opcNodeToReg, dest, dest)
   elif isAddr and isGlobal(n.sons[0]):
     gen(c, n.sons[0], dest, flags+{gfAddrOf})
   else:
diff --git a/tests/vm/tstaticprintseq.nim b/tests/vm/tstaticprintseq.nim
index b002d366c..e4a6aa081 100644
--- a/tests/vm/tstaticprintseq.nim
+++ b/tests/vm/tstaticprintseq.nim
@@ -18,7 +18,8 @@ bb
 aa
 bb
 24
-2147483647 2147483647'''
+2147483647 2147483647
+5'''
 """
 
 const s = @[1,2,3]
@@ -80,3 +81,12 @@ static:
 static:
   var foo2 = int32.high
   echo foo2, " ", int32.high
+
+# bug #1329
+
+static:
+    var a: ref int
+    new(a)
+    a[] = 5
+
+    echo a[]