summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-02-16 11:15:27 +0100
committerAraq <rumpf_a@web.de>2017-02-16 11:15:43 +0100
commit6499462303f1e4ccc8e9a3174985f563e688f566 (patch)
tree8b2236ec53ee3549745337f67feb94c7aa2bdfde /tests
parent71026cec6e28d89677be0b5b3db4f8f79ee4bb3e (diff)
downloadNim-6499462303f1e4ccc8e9a3174985f563e688f566.tar.gz
fixes #5402
Diffstat (limited to 'tests')
-rw-r--r--tests/ccgbugs/tgeneric_smallobj_asgn_opt.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ccgbugs/tgeneric_smallobj_asgn_opt.nim b/tests/ccgbugs/tgeneric_smallobj_asgn_opt.nim
new file mode 100644
index 000000000..919dc3fc1
--- /dev/null
+++ b/tests/ccgbugs/tgeneric_smallobj_asgn_opt.nim
@@ -0,0 +1,26 @@
+discard """
+  output: '''false'''
+"""
+
+# bug #5402
+
+import lists
+
+type
+  Container[T] = ref object
+    obj: T
+
+  ListOfContainers[T] = ref object
+    list: DoublyLinkedList[Container[T]]
+
+proc contains[T](this: ListOfContainers[T], obj: T): bool =
+  for item in this.list.items():
+    if item.obj == obj: return true
+  return false
+
+proc newListOfContainers[T](): ListOfContainers[T] =
+  new(result)
+  result.list = initDoublyLinkedList[Container[T]]()
+
+let q = newListOfContainers[int64]()
+echo q.contains(123)