summary refs log tree commit diff stats
path: root/tests/vm/tsetlen.nim
blob: 9fd30f33193ef106377d12f04b1a1874282c3bde (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
27
28
29
30
type Foo = object
  index: int

block:
  proc fun[T]() =
    var foo: T
    var n = 10

    var foos: seq[T]
    foos.setLen n

    n.inc
    foos.setLen n

    for i in 0 ..< n:
      let temp = foos[i]
      when T is object:
        doAssert temp.index == 0
      when T is ref object:
        doAssert temp == nil
      doAssert temp == foo

  static:
    fun[Foo]()
    fun[int]()
    fun[float]()
    fun[string]()
    fun[(int, string)]()
    fun[ref Foo]()
    fun[seq[int]]()