summary refs log tree commit diff stats
path: root/tests/arc/tarc_orc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arc/tarc_orc.nim')
-rw-r--r--tests/arc/tarc_orc.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim
index 2fbb2e792..387baa28f 100644
--- a/tests/arc/tarc_orc.nim
+++ b/tests/arc/tarc_orc.nim
@@ -59,3 +59,33 @@ proc bug(): seq[Obj] =
 # bug #19990
 let s = bug()
 doAssert s[0] == (value: 1, arr: @[1])
+
+block: # bug #21974
+  type Test[T] = ref object
+      values : seq[T]
+      counter: int
+
+  proc newTest[T](): Test[T] =
+      result         = new(Test[T])
+      result.values  = newSeq[T](16)
+      result.counter = 0
+
+  proc push[T](self: Test[T], value: T) =
+      self.counter += 1
+      if self.counter >= self.values.len:
+          self.values.setLen(self.values.len * 2)
+      self.values[self.counter - 1] = value
+
+  proc pop[T](self: Test[T]): T =
+      result         = self.values[0]
+      self.values[0] = self.values[self.counter - 1] # <--- This line
+      self.counter  -= 1
+
+
+  type X = tuple
+      priority: int
+      value   : string
+
+  var a = newTest[X]()
+  a.push((1, "One"))
+  doAssert a.pop.value == "One"