summary refs log tree commit diff stats
path: root/tests/ccgbugs/tgeneric_smallobj_asgn_opt.nim
blob: 919dc3fc1906423eb9bfc3a903fb7c1fe817359d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)