mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-28 18:24:01 +00:00
fixes #23748
This commit is contained in:
committed by
GitHub
parent
c88894bf76
commit
4202b606b1
31
tests/destructor/t23748.nim
Normal file
31
tests/destructor/t23748.nim
Normal file
@@ -0,0 +1,31 @@
|
||||
discard """
|
||||
matrix: "--gc:refc; --gc:arc"
|
||||
output: '''
|
||||
hello 42
|
||||
hello 42
|
||||
len = 2
|
||||
'''
|
||||
"""
|
||||
|
||||
# bug #23748
|
||||
|
||||
type
|
||||
O = ref object
|
||||
s: string
|
||||
cb: seq[proc()]
|
||||
|
||||
proc push1(o: O, i: int) =
|
||||
let o = o
|
||||
echo o.s, " ", i
|
||||
o.cb.add(proc() = echo o.s, " ", i)
|
||||
|
||||
proc push2(o: O, i: int) =
|
||||
let o = o
|
||||
echo o.s, " ", i
|
||||
proc p() = echo o.s, " ", i
|
||||
o.cb.add(p)
|
||||
|
||||
let o = O(s: "hello", cb: @[])
|
||||
o.push1(42)
|
||||
o.push2(42)
|
||||
echo "len = ", o.cb.len
|
||||
Reference in New Issue
Block a user