summary refs log tree commit diff stats
path: root/tests/arc/tarcmisc.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-05-29 23:35:57 +0200
committerGitHub <noreply@github.com>2020-05-29 23:35:57 +0200
commit3105909f887f2240c2a7a7071b37e1253a70e3e2 (patch)
treecbf6376162adf7acaae93742b9c49e01174c974f /tests/arc/tarcmisc.nim
parentcb6eb5268fffea891501c0aed7510d7354c16159 (diff)
downloadNim-3105909f887f2240c2a7a7071b37e1253a70e3e2.tar.gz
fixes #14495 [backport:1.2] (#14496)
Diffstat (limited to 'tests/arc/tarcmisc.nim')
-rw-r--r--tests/arc/tarcmisc.nim48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index 24f02959c..898efd138 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -4,6 +4,17 @@ discard """
 destroyed: false
 destroyed: false
 1
+(x: "0")
+(x: "1")
+(x: "2")
+(x: "3")
+(x: "4")
+(x: "5")
+(x: "6")
+(x: "7")
+(x: "8")
+(x: "9")
+(x: "10")
 closed
 destroying variable
 '''
@@ -99,10 +110,10 @@ type
   MyType = object
     a: seq[int]
 
-proc re(x: static[string]): static MyType = 
+proc re(x: static[string]): static MyType =
   MyType()
 
-proc match(inp: string, rg: static MyType) = 
+proc match(inp: string, rg: static MyType) =
   doAssert rg.a.len == 0
 
 match("ac", re"a(b|c)")
@@ -125,13 +136,40 @@ var game*: Game
 #------------------------------------------------------------------------------
 # issue #14333
 
-type  
+type
   SimpleLoop = object
-  
+
   Lsg = object
     loops: seq[ref SimpleLoop]
     root: ref SimpleLoop
 
 var lsg: Lsg
 lsg.loops.add lsg.root
-echo lsg.loops.len
\ No newline at end of file
+echo lsg.loops.len
+
+# bug #14495
+type
+  Gah = ref object
+    x: string
+
+proc bug14495 =
+  var owners: seq[Gah]
+  for i in 0..10:
+    owners.add Gah(x: $i)
+
+  var x: seq[Gah]
+  for i in 0..10:
+    x.add owners[i]
+
+  for i in 0..100:
+    setLen(x, 0)
+    setLen(x, 10)
+
+  for i in 0..x.len-1:
+    if x[i] != nil:
+      echo x[i][]
+
+  for o in owners:
+    echo o[]
+
+bug14495()