Fix capture for object types (#13315)
* Fix capture for object|tuple|... types * Add test case
This commit is contained in:
parent
45a5c64c9a
commit
d43e5bef39
2 changed files with 17 additions and 3 deletions
|
|
@ -1,6 +1,9 @@
|
|||
discard """
|
||||
output: '''
|
||||
to be, or not to be'''
|
||||
to be, or not to be
|
||||
(v: 1)
|
||||
(v: 1)
|
||||
'''
|
||||
joinable: false
|
||||
"""
|
||||
|
||||
|
|
@ -9,4 +12,15 @@ import sequtils, sugar
|
|||
let m = @[proc (s: string): string = "to " & s, proc (s: string): string = "not to " & s]
|
||||
var l = m.mapIt(capture([it], proc (s: string): string = it(s)))
|
||||
let r = l.mapIt(it("be"))
|
||||
echo r[0] & ", or " & r[1]
|
||||
echo r[0] & ", or " & r[1]
|
||||
|
||||
type O = object
|
||||
v: int
|
||||
var o = O(v: 1)
|
||||
var execute: proc()
|
||||
capture [o]:
|
||||
execute = proc() =
|
||||
echo o
|
||||
execute()
|
||||
o.v = -1
|
||||
execute()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue