fixes #14495 [backport:1.2] (#14496)

(cherry picked from commit 3105909f88)
This commit is contained in:
Andreas Rumpf
2020-05-29 23:35:57 +02:00
committed by narimiran
parent 051f4ffad9
commit aec0d583d1
2 changed files with 88 additions and 4 deletions

View File

@@ -3,6 +3,18 @@ discard """
123xyzabc
destroyed: false
destroyed: false
1
(x: "0")
(x: "1")
(x: "2")
(x: "3")
(x: "4")
(x: "5")
(x: "6")
(x: "7")
(x: "8")
(x: "9")
(x: "10")
closed
destroying variable
'''
@@ -89,3 +101,75 @@ let
assert n.sortedByIt(it) == @["b", "c"], "fine"
assert q.sortedByIt(it[0]) == @[("b", "1"), ("c", "2")], "fails under arc"
#------------------------------------------------------------------------------
# issue #14236
type
MyType = object
a: seq[int]
proc re(x: static[string]): static MyType =
MyType()
proc match(inp: string, rg: static MyType) =
doAssert rg.a.len == 0
match("ac", re"a(b|c)")
#------------------------------------------------------------------------------
# issue #14243
type
Game* = ref object
proc free*(game: Game) =
let a = 5
proc newGame*(): Game =
new(result, free)
var game*: Game
#------------------------------------------------------------------------------
# issue #14333
type
SimpleLoop = object
Lsg = object
loops: seq[ref SimpleLoop]
root: ref SimpleLoop
var lsg: Lsg
lsg.loops.add lsg.root
echo lsg.loops.len
# bug #14495
type
Gah = ref object
x: string
proc bug14495 =
var owners: seq[Gah]
for i in 0..10:
owners.add Gah(x: $i)
var x: seq[Gah]
for i in 0..10:
x.add owners[i]
for i in 0..100:
setLen(x, 0)
setLen(x, 10)
for i in 0..x.len-1:
if x[i] != nil:
echo x[i][]
for o in owners:
echo o[]
bug14495()