fix #9872: setLen now works properly at CT [backport]
This commit is contained in:
parent
32a08d4450
commit
f838b1e6c1
2 changed files with 32 additions and 16 deletions
30
tests/vm/tsetlen.nim
Normal file
30
tests/vm/tsetlen.nim
Normal file
|
|
@ -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]]()
|
||||
Loading…
Add table
Add a link
Reference in a new issue