[backport] fixes #23748; do not skip materializing temporaries for proc arguments (#23769)

fixes #23748
This commit is contained in:
Alexander Kernozhitsky
2024-06-30 14:10:10 +02:00
committed by GitHub
parent c88894bf76
commit 4202b606b1
3 changed files with 48 additions and 4 deletions

View 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