diff options
Diffstat (limited to 'tests/ccgbugs/twrongrefcounting.nim')
-rw-r--r-- | tests/ccgbugs/twrongrefcounting.nim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ccgbugs/twrongrefcounting.nim b/tests/ccgbugs/twrongrefcounting.nim new file mode 100644 index 000000000..8ebaf4058 --- /dev/null +++ b/tests/ccgbugs/twrongrefcounting.nim @@ -0,0 +1,33 @@ +discard """ + output: '''ok''' + cmd: "nim c -r --gc:refc -d:useGcAssert -d:useSysAssert -d:fulldebug -d:smokeCycles $file" +""" + +# bug #9825 +func empty(T: typedesc): T = discard +const emptyChunk = @(empty(array[10, byte])) + +var lst: seq[seq[byte]] +lst.add emptyChunk + +doAssert($lst == "@[@[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]") + + +# bug #6234 +type + Foo = ref object + s: seq[Bar] + Bar = ref object + f: Foo + +proc test() = + var f = Foo.new() + for i in 0 .. 5: + f.s = @[] + for j in 0 .. 5: + var b = Bar.new() + b.f = f + f.s.add(b) + +test() +echo "ok" |