diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-05 21:27:40 -0800 |
---|---|---|
committer | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-08 14:33:42 -0800 |
commit | f838b1e6c14c8c505eea6e2107295f166c67f346 (patch) | |
tree | e7fcc6a6ba8cd53a06f2b1caa80356de0b2ffb7c /tests | |
parent | 32a08d4450a3b8af905d8b04339917cc91061dd3 (diff) | |
download | Nim-f838b1e6c14c8c505eea6e2107295f166c67f346.tar.gz |
fix #9872: setLen now works properly at CT [backport]
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vm/tsetlen.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/vm/tsetlen.nim b/tests/vm/tsetlen.nim new file mode 100644 index 000000000..9fd30f331 --- /dev/null +++ b/tests/vm/tsetlen.nim @@ -0,0 +1,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]]() |