From 124ed521bcfcd0cd281c98575e65220dfdfb22d0 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Sun, 2 Feb 2020 02:16:13 +0100 Subject: [PATCH] Add test case --- tests/closure/tcapture.nim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/closure/tcapture.nim b/tests/closure/tcapture.nim index 304a76285fb68..11345a99aed32 100644 --- a/tests/closure/tcapture.nim +++ b/tests/closure/tcapture.nim @@ -2,6 +2,8 @@ discard """ output: ''' to be, or not to be''' joinable: false +(v: 1) +(v: 1) """ import sequtils, sugar @@ -9,4 +11,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] \ No newline at end of file +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()